Commits

Andriy Kornatskyy committed f88e4d7

Added functional tests for if modified since and if none match checks.

Comments (0)

Files changed (2)

demos/public/src/public/web/tests/benchmark_views.py

             self.test_static_files,
             self.test_static_file_not_found,
             self.test_static_file_forbidden,
+            self.test_static_file_if_modified_since,
+            self.test_static_file_if_none_match,
             self.test_static_file_gzip,
             self.test_head_static_file
             ), 1000)
                 'test_widgets': 0.52,
                 'test_widgets_with_errors': 0.51,
                 'test_static_files': 1.655,
-                'test_static_file_not_found': 0.64,
-                'test_static_file_forbidden': 0.62,
+                'test_static_file_not_found': 2.0,
+                'test_static_file_forbidden': 2.2,
+                'test_static_file_if_modified_since': 7.0,
+                'test_static_file_if_none_match': 11.3,
                 'test_static_file_gzip': 8.91,
                 'test_head_static_file': 9.08
         })

demos/public/src/public/web/tests/test_views.py

         for static_file in [
                 '/favicon.ico',
                 '/static/css/site.css',
+                '/static/img/error.png',
                 '/static/js/core.js',
                 '/static/js/autocomplete.js',
                 '/static/js/jquery-1.7.1.min.js',
         """ Ensure 404 status code for non existing
             static content.
         """
-        self.client.get('/static/css/unknown.css')
-        assert 404 == self.client.follow()
+        assert 302 == self.client.get('/static/css/unknown.css')
+        assert '404' in self.client.headers['Location'][0]
 
     def test_static_file_forbidden(self):
         """ Ensure 403 status code for forbidden
             static content.
         """
-        self.client.get('/static/js/')
-        assert 403 == self.client.follow()
+        assert 302 == self.client.get('/static/../templates/')
+        assert '403' in self.client.headers['Location'][0]
 
     def test_static_file_gzip(self):
         """
         })
         assert 'gzip' in self.client.headers['Content-Encoding']
 
+    def test_static_file_if_modified_since(self):
+        """
+        """
+        assert 304 == self.client.get('/static/css/site.css', environ={
+            'HTTP_IF_MODIFIED_SINCE': 'Fri, 24 Feb 2012 14:11:30 GMT'
+        })
+
+    def test_static_file_if_none_match(self):
+        """
+        """
+        assert 304 == self.client.get('/static/css/site.css', environ={
+            'HTTP_IF_NONE_MATCH': '"4f479a92"'
+        })
+
     def test_head_static_file(self):
         """
         """