[web/test] move unittest_controller to RepoAccess test API
authorJulien Cristau <julien.cristau@logilab.fr>
Wed, 02 Apr 2014 17:03:46 +0200
changeset 9644 2683c9f9a6b7
parent 9643 421604863753
child 9645 0b809c852266
[web/test] move unittest_controller to RepoAccess test API
web/test/unittest_controller.py
--- a/web/test/unittest_controller.py	Wed Apr 02 16:56:26 2014 +0200
+++ b/web/test/unittest_controller.py	Wed Apr 02 17:03:46 2014 +0200
@@ -28,30 +28,32 @@
 class BaseControllerTC(testlib.CubicWebTC):
 
     def test_parse_datetime_ok(self):
-        ctrl = self.vreg['controllers'].select('view', self.request())
-        pd = ctrl._cw.parse_datetime
-        self.assertIsInstance(pd('2006/06/24 12:18'), datetime)
-        self.assertIsInstance(pd('2006/06/24'), date)
-        self.assertIsInstance(pd('2006/06/24 12:18', 'Datetime'), datetime)
-        self.assertIsInstance(pd('2006/06/24', 'Datetime'), datetime)
-        self.assertIsInstance(pd('2006/06/24', 'Date'), date)
-        self.assertIsInstance(pd('12:18', 'Time'), time)
+        with self.admin_access.web_request() as req:
+            ctrl = self.vreg['controllers'].select('view', req)
+            pd = ctrl._cw.parse_datetime
+            self.assertIsInstance(pd('2006/06/24 12:18'), datetime)
+            self.assertIsInstance(pd('2006/06/24'), date)
+            self.assertIsInstance(pd('2006/06/24 12:18', 'Datetime'), datetime)
+            self.assertIsInstance(pd('2006/06/24', 'Datetime'), datetime)
+            self.assertIsInstance(pd('2006/06/24', 'Date'), date)
+            self.assertIsInstance(pd('12:18', 'Time'), time)
 
     def test_parse_datetime_ko(self):
-        ctrl = self.vreg['controllers'].select('view', self.request())
-        pd = ctrl._cw.parse_datetime
-        self.assertRaises(ValueError,
-                          pd, '2006/06/24 12:188', 'Datetime')
-        self.assertRaises(ValueError,
-                          pd, '2006/06/240', 'Datetime')
-        self.assertRaises(ValueError,
-                          pd, '2006/06/24 12:18', 'Date')
-        self.assertRaises(ValueError,
-                          pd, '2006/24/06', 'Date')
-        self.assertRaises(ValueError,
-                          pd, '2006/06/240', 'Date')
-        self.assertRaises(ValueError,
-                          pd, '12:188', 'Time')
+        with self.admin_access.web_request() as req:
+            ctrl = self.vreg['controllers'].select('view', req)
+            pd = ctrl._cw.parse_datetime
+            self.assertRaises(ValueError,
+                              pd, '2006/06/24 12:188', 'Datetime')
+            self.assertRaises(ValueError,
+                              pd, '2006/06/240', 'Datetime')
+            self.assertRaises(ValueError,
+                              pd, '2006/06/24 12:18', 'Date')
+            self.assertRaises(ValueError,
+                              pd, '2006/24/06', 'Date')
+            self.assertRaises(ValueError,
+                              pd, '2006/06/240', 'Date')
+            self.assertRaises(ValueError,
+                              pd, '12:188', 'Time')
 
 if __name__ == '__main__':
     unittest_main()