[test] silence warnings for unittest_schema by upgrading to new 3.19 API
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 04 Apr 2014 12:46:06 +0200
changeset 9640 26ea1c4387bf
parent 9639 74b3db5bb41d
child 9641 4147cc32371d
[test] silence warnings for unittest_schema by upgrading to new 3.19 API
test/unittest_schema.py
--- a/test/unittest_schema.py	Fri Apr 04 12:45:12 2014 +0200
+++ b/test/unittest_schema.py	Fri Apr 04 12:46:06 2014 +0200
@@ -329,6 +329,7 @@
         self.assertEqual(normalize_expression('X  bla Y,Y blur Z  ,  Z zigoulou   X '),
                                                'X bla Y, Y blur Z, Z zigoulou X')
 
+
 class RQLExpressionTC(TestCase):
     def test_comparison(self):
         self.assertEqual(ERQLExpression('X is CWUser', 'X', 0),
@@ -336,6 +337,7 @@
         self.assertNotEqual(ERQLExpression('X is CWUser', 'X', 0),
                              ERQLExpression('X is CWGroup', 'X', 0))
 
+
 class GuessRrqlExprMainVarsTC(TestCase):
     def test_exists(self):
         mainvars = guess_rrqlexpr_mainvars(normalize_expression('NOT EXISTS(O team_competition C, C level < 3, C concerns S)'))
@@ -345,15 +347,19 @@
 class RQLConstraintTC(CubicWebTC):
     def test_user_constraint(self):
         cstr = RQLConstraint('U identity O')
-        anoneid = self.execute('Any X WHERE X login "anon"')[0][0]
-        self.assertRaises(ValidationError, cstr.repo_check, self.session, 1, 'rel', anoneid)
-        self.assertEqual(cstr.repo_check(self.session, 1, self.session.user.eid),
-        None) # no validation error, constraint checked
+        with self.admin_access.repo_cnx() as cnx:
+            anoneid = cnx.execute('Any X WHERE X login "anon"')[0][0]
+            self.assertRaises(ValidationError,
+                              cstr.repo_check, cnx, 1, 'rel', anoneid)
+            self.assertEqual(cstr.repo_check(cnx, 1, cnx.user.eid),
+                             None) # no validation error, constraint checked
+
 
 class WorkflowShemaTC(CubicWebTC):
     def test_trinfo_default_format(self):
-        tr = self.request().user.cw_adapt_to('IWorkflowable').fire_transition('deactivate')
-        self.assertEqual(tr.comment_format, 'text/plain')
+        with self.admin_access.web_request() as req:
+            tr = req.user.cw_adapt_to('IWorkflowable').fire_transition('deactivate')
+            self.assertEqual(tr.comment_format, 'text/plain')
 
 
 class CompositeSchemaTC(CubicWebTC):