web/test/unittest_views_basecontrollers.py
changeset 10968 9c6c3e68422e
parent 10932 cb217b2b3463
--- a/web/test/unittest_views_basecontrollers.py	Wed Dec 09 15:51:20 2015 +0100
+++ b/web/test/unittest_views_basecontrollers.py	Tue Dec 08 16:27:05 2015 +0100
@@ -23,12 +23,12 @@
 import lxml
 
 from logilab.common.testlib import unittest_main
-
 from logilab.common.decorators import monkeypatch
 
 from cubicweb import Binary, NoSelectableObject, ValidationError
 from cubicweb.schema import RRQLExpression
 from cubicweb.devtools.testlib import CubicWebTC
+from cubicweb.devtools.webtest import CubicWebTestTC
 from cubicweb.utils import json_dumps
 from cubicweb.uilib import rql_for_eid
 from cubicweb.web import Redirect, RemoteCallFailed
@@ -41,6 +41,19 @@
 from cubicweb.server.hook import Hook, Operation
 from cubicweb.predicates import is_instance
 
+
+class ViewControllerTC(CubicWebTestTC):
+    def test_view_ctrl_with_valid_cache_headers(self):
+        resp = self.webapp.get('/manage')
+        self.assertEqual(resp.etag, 'manage/guests')
+        self.assertEqual(resp.status_code, 200)
+        cache_headers = {'if-modified-since': resp.headers['Last-Modified'],
+                         'if-none-match': resp.etag}
+        resp = self.webapp.get('/manage', headers=cache_headers)
+        self.assertEqual(resp.status_code, 304)
+        self.assertEqual(len(resp.body), 0)
+
+
 def req_form(user):
     return {'eid': [str(user.eid)],
             '_cw_entity_fields:%s' % user.eid: '_cw_generic_field',