327 |
327 |
328 def test(self): |
328 def test(self): |
329 self.assertEqual(normalize_expression('X bla Y,Y blur Z , Z zigoulou X '), |
329 self.assertEqual(normalize_expression('X bla Y,Y blur Z , Z zigoulou X '), |
330 'X bla Y, Y blur Z, Z zigoulou X') |
330 'X bla Y, Y blur Z, Z zigoulou X') |
331 |
331 |
|
332 |
332 class RQLExpressionTC(TestCase): |
333 class RQLExpressionTC(TestCase): |
333 def test_comparison(self): |
334 def test_comparison(self): |
334 self.assertEqual(ERQLExpression('X is CWUser', 'X', 0), |
335 self.assertEqual(ERQLExpression('X is CWUser', 'X', 0), |
335 ERQLExpression('X is CWUser', 'X', 0)) |
336 ERQLExpression('X is CWUser', 'X', 0)) |
336 self.assertNotEqual(ERQLExpression('X is CWUser', 'X', 0), |
337 self.assertNotEqual(ERQLExpression('X is CWUser', 'X', 0), |
337 ERQLExpression('X is CWGroup', 'X', 0)) |
338 ERQLExpression('X is CWGroup', 'X', 0)) |
338 |
339 |
|
340 |
339 class GuessRrqlExprMainVarsTC(TestCase): |
341 class GuessRrqlExprMainVarsTC(TestCase): |
340 def test_exists(self): |
342 def test_exists(self): |
341 mainvars = guess_rrqlexpr_mainvars(normalize_expression('NOT EXISTS(O team_competition C, C level < 3, C concerns S)')) |
343 mainvars = guess_rrqlexpr_mainvars(normalize_expression('NOT EXISTS(O team_competition C, C level < 3, C concerns S)')) |
342 self.assertEqual(mainvars, set(['S', 'O'])) |
344 self.assertEqual(mainvars, set(['S', 'O'])) |
343 |
345 |
344 |
346 |
345 class RQLConstraintTC(CubicWebTC): |
347 class RQLConstraintTC(CubicWebTC): |
346 def test_user_constraint(self): |
348 def test_user_constraint(self): |
347 cstr = RQLConstraint('U identity O') |
349 cstr = RQLConstraint('U identity O') |
348 anoneid = self.execute('Any X WHERE X login "anon"')[0][0] |
350 with self.admin_access.repo_cnx() as cnx: |
349 self.assertRaises(ValidationError, cstr.repo_check, self.session, 1, 'rel', anoneid) |
351 anoneid = cnx.execute('Any X WHERE X login "anon"')[0][0] |
350 self.assertEqual(cstr.repo_check(self.session, 1, self.session.user.eid), |
352 self.assertRaises(ValidationError, |
351 None) # no validation error, constraint checked |
353 cstr.repo_check, cnx, 1, 'rel', anoneid) |
|
354 self.assertEqual(cstr.repo_check(cnx, 1, cnx.user.eid), |
|
355 None) # no validation error, constraint checked |
|
356 |
352 |
357 |
353 class WorkflowShemaTC(CubicWebTC): |
358 class WorkflowShemaTC(CubicWebTC): |
354 def test_trinfo_default_format(self): |
359 def test_trinfo_default_format(self): |
355 tr = self.request().user.cw_adapt_to('IWorkflowable').fire_transition('deactivate') |
360 with self.admin_access.web_request() as req: |
356 self.assertEqual(tr.comment_format, 'text/plain') |
361 tr = req.user.cw_adapt_to('IWorkflowable').fire_transition('deactivate') |
|
362 self.assertEqual(tr.comment_format, 'text/plain') |
357 |
363 |
358 |
364 |
359 class CompositeSchemaTC(CubicWebTC): |
365 class CompositeSchemaTC(CubicWebTC): |
360 composites = { |
366 composites = { |
361 'BaseTransition': [('condition', 'BaseTransition', 'RQLExpression', 'subject'), |
367 'BaseTransition': [('condition', 'BaseTransition', 'RQLExpression', 'subject'), |