74 'if-modified-since': req.get_response_header('last-modified', raw=True), |
74 'if-modified-since': req.get_response_header('last-modified', raw=True), |
75 } |
75 } |
76 with self._publish_static_files(fname, next_headers) as req: |
76 with self._publish_static_files(fname, next_headers) as req: |
77 self.assertEqual(304, req.status_out) |
77 self.assertEqual(304, req.status_out) |
78 |
78 |
|
79 def _check_datafile_redirect(self, fname, expected): |
|
80 with self._publish_static_files(fname) as req: |
|
81 self.assertEqual(302, req.status_out) |
|
82 self.assertEqual(req.get_response_header('location'), |
|
83 req.base_url() + expected) |
|
84 |
79 def _check_no_datafile(self, fname): |
85 def _check_no_datafile(self, fname): |
80 with self._publish_static_files(fname) as req: |
86 with self._publish_static_files(fname) as req: |
81 self.assertEqual(404, req.status_out) |
87 self.assertEqual(404, req.status_out) |
82 |
88 |
83 def test_static_data_mode(self): |
89 def test_static_data_mode(self): |
88 self._check_datafile_ok('data/cubicweb.css') |
94 self._check_datafile_ok('data/cubicweb.css') |
89 self._check_no_datafile('data/does/not/exist') |
95 self._check_no_datafile('data/does/not/exist') |
90 self._check_no_datafile('data/%s/cubicweb.css' % ('0'*len(hash))) |
96 self._check_no_datafile('data/%s/cubicweb.css' % ('0'*len(hash))) |
91 |
97 |
92 with tempattr(self.vreg.config, 'mode', 'notest'): |
98 with tempattr(self.vreg.config, 'mode', 'notest'): |
93 self._check_datafile_ok('data/cubicweb.css') |
99 self.config._init_base_url() # reset config.datadir_url |
|
100 self._check_datafile_redirect('data/cubicweb.css', 'data/%s/cubicweb.css' % hash) |
94 self._check_datafile_ok('data/%s/cubicweb.css' % hash) |
101 self._check_datafile_ok('data/%s/cubicweb.css' % hash) |
95 self._check_no_datafile('data/does/not/exist') |
102 self._check_no_datafile('data/%s/does/not/exist' % hash) |
96 self._check_no_datafile('data/%s/cubicweb.css' % ('0'*len(hash))) |
103 self._check_datafile_redirect('data/%s/does/not/exist' % ('0'*len(hash)), |
|
104 'data/%s/%s/does/not/exist' % (hash, '0'*len(hash))) |
97 |
105 |
98 |
106 |
99 class ConcatFilesTC(CubicWebTC): |
107 class ConcatFilesTC(CubicWebTC): |
100 |
108 |
101 tags = CubicWebTC.tags | Tags('static_controller', 'concat') |
109 tags = CubicWebTC.tags | Tags('static_controller', 'concat') |