[test] reindent
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 08 Dec 2011 13:16:10 +0100
changeset 8113 1e8c92202f44
parent 8112 d3f1e28d5bdb
child 8114 8311cc3b472a
[test] reindent
test/unittest_rqlrewrite.py
--- a/test/unittest_rqlrewrite.py	Wed Dec 07 10:53:05 2011 +0100
+++ b/test/unittest_rqlrewrite.py	Thu Dec 08 13:16:10 2011 +0100
@@ -111,9 +111,9 @@
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'X'): (constraint,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             u"Any C WHERE C is Card, B eid %(D)s, "
-                             "EXISTS(C in_state A, B in_group E, F require_state A, "
-                             "F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission)")
+                         u"Any C WHERE C is Card, B eid %(D)s, "
+                         "EXISTS(C in_state A, B in_group E, F require_state A, "
+                         "F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission)")
 
     def test_multiple_var(self):
         card_constraint = ('X in_state S, U in_group G, P require_state S,'
@@ -123,12 +123,13 @@
         rqlst = parse('Any S WHERE S documented_by C, C eid %(u)s')
         rewrite(rqlst, {('C', 'X'): (card_constraint,), ('S', 'X'): affaire_constraints},
                 kwargs)
-        self.assertMultiLineEqual(rqlst.as_string(),
-                             "Any S WHERE S documented_by C, C eid %(u)s, B eid %(D)s, "
-                             "EXISTS(C in_state A, B in_group E, F require_state A, "
-                             "F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission), "
-                             "(EXISTS(S ref LIKE 'PUBLIC%')) OR (EXISTS(B in_group G, G name 'public', G is CWGroup)), "
-                             "S is Affaire")
+        self.assertMultiLineEqual(
+            rqlst.as_string(),
+            "Any S WHERE S documented_by C, C eid %(u)s, B eid %(D)s, "
+            "EXISTS(C in_state A, B in_group E, F require_state A, "
+            "F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission), "
+            "(EXISTS(S ref LIKE 'PUBLIC%')) OR (EXISTS(B in_group G, G name 'public', G is CWGroup)), "
+            "S is Affaire")
         self.assertTrue('D' in kwargs)
 
     def test_or(self):
@@ -136,9 +137,9 @@
         rqlst = parse('Any S WHERE S owned_by C, C eid %(u)s, S is in (CWUser, CWGroup)')
         rewrite(rqlst, {('C', 'X'): (constraint,)}, {'u':1})
         self.assertEqual(rqlst.as_string(),
-                             "Any S WHERE S owned_by C, C eid %(u)s, S is IN(CWUser, CWGroup), A eid %(B)s, "
-                             "EXISTS((C identity A) OR (C in_state D, E identity A, "
-                             "E in_state D, D name 'subscribed'), D is State, E is CWUser)")
+                         "Any S WHERE S owned_by C, C eid %(u)s, S is IN(CWUser, CWGroup), A eid %(B)s, "
+                         "EXISTS((C identity A) OR (C in_state D, E identity A, "
+                         "E in_state D, D name 'subscribed'), D is State, E is CWUser)")
 
     def test_simplified_rqlst(self):
         constraint = ('X in_state S, U in_group G, P require_state S,'
@@ -146,9 +147,9 @@
         rqlst = parse('Any 2') # this is the simplified rql st for Any X WHERE X eid 12
         rewrite(rqlst, {('2', 'X'): (constraint,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             u"Any 2 WHERE B eid %(C)s, "
-                             "EXISTS(2 in_state A, B in_group D, E require_state A, "
-                             "E name 'read', E require_group D, A is State, D is CWGroup, E is CWPermission)")
+                         u"Any 2 WHERE B eid %(C)s, "
+                         "EXISTS(2 in_state A, B in_group D, E require_state A, "
+                         "E name 'read', E require_group D, A is State, D is CWGroup, E is CWPermission)")
 
     def test_optional_var_1(self):
         constraint = ('X in_state S, U in_group G, P require_state S,'
@@ -156,10 +157,10 @@
         rqlst = parse('Any A,C WHERE A documented_by C?')
         rewrite(rqlst, {('C', 'X'): (constraint,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any A,C WHERE A documented_by C?, A is Affaire "
-                             "WITH C BEING "
-                             "(Any C WHERE EXISTS(C in_state B, D in_group F, G require_state B, G name 'read', "
-                             "G require_group F), D eid %(A)s, C is Card)")
+                         "Any A,C WHERE A documented_by C?, A is Affaire "
+                         "WITH C BEING "
+                         "(Any C WHERE EXISTS(C in_state B, D in_group F, G require_state B, G name 'read', "
+                         "G require_group F), D eid %(A)s, C is Card)")
 
     def test_optional_var_2(self):
         constraint = ('X in_state S, U in_group G, P require_state S,'
@@ -167,11 +168,11 @@
         rqlst = parse('Any A,C,T WHERE A documented_by C?, C title T')
         rewrite(rqlst, {('C', 'X'): (constraint,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any A,C,T WHERE A documented_by C?, A is Affaire "
-                             "WITH C,T BEING "
-                             "(Any C,T WHERE C title T, EXISTS(C in_state B, D in_group F, "
-                             "G require_state B, G name 'read', G require_group F), "
-                             "D eid %(A)s, C is Card)")
+                         "Any A,C,T WHERE A documented_by C?, A is Affaire "
+                         "WITH C,T BEING "
+                         "(Any C,T WHERE C title T, EXISTS(C in_state B, D in_group F, "
+                         "G require_state B, G name 'read', G require_group F), "
+                         "D eid %(A)s, C is Card)")
 
     def test_optional_var_3(self):
         constraint1 = ('X in_state S, U in_group G, P require_state S,'
@@ -180,11 +181,11 @@
         rqlst = parse('Any A,C,T WHERE A documented_by C?, C title T')
         rewrite(rqlst, {('C', 'X'): (constraint1, constraint2)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any A,C,T WHERE A documented_by C?, A is Affaire "
-                             "WITH C,T BEING (Any C,T WHERE C title T, "
-                             "EXISTS(C in_state B, D in_group F, G require_state B, G name 'read', G require_group F), "
-                             "D eid %(A)s, C is Card, "
-                             "EXISTS(C in_state E, E name 'public'))")
+                         "Any A,C,T WHERE A documented_by C?, A is Affaire "
+                         "WITH C,T BEING (Any C,T WHERE C title T, "
+                         "EXISTS(C in_state B, D in_group F, G require_state B, G name 'read', G require_group F), "
+                         "D eid %(A)s, C is Card, "
+                         "EXISTS(C in_state E, E name 'public'))")
 
     def test_optional_var_4(self):
         constraint1 = 'A created_by U, X documented_by A'
@@ -242,11 +243,11 @@
         rqlst = parse('Any A,W WHERE A inlined_card C?, C inlined_note N, '
                       'N inlined_affaire W')
         rewrite(rqlst, {('C', 'X'): (c1,)}, {})
-        self.failUnlessEqual(rqlst.as_string(),
-                             'Any A,W WHERE A inlined_card C?, A is Affaire '
-                             'WITH C,N,W BEING (Any C,N,W WHERE C inlined_note N, '
-                             'N inlined_affaire W, EXISTS(C require_permission B), '
-                             'C is Card, N is Note, W is Affaire)')
+        self.assertEqual(rqlst.as_string(),
+                         'Any A,W WHERE A inlined_card C?, A is Affaire '
+                         'WITH C,N,W BEING (Any C,N,W WHERE C inlined_note N, '
+                         'N inlined_affaire W, EXISTS(C require_permission B), '
+                         'C is Card, N is Note, W is Affaire)')
 
     def test_relation_optimization_1_lhs(self):
         # since Card in_state State as monovalued cardinality, the in_state
@@ -256,16 +257,16 @@
         rqlst = parse('Card C WHERE C in_state STATE')
         rewrite(rqlst, {('C', 'X'): (snippet,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any C WHERE C in_state STATE, C is Card, "
-                             "EXISTS(STATE name 'hop'), STATE is State")
+                         "Any C WHERE C in_state STATE, C is Card, "
+                         "EXISTS(STATE name 'hop'), STATE is State")
 
     def test_relation_optimization_1_rhs(self):
         snippet = ('TW subworkflow_exit X, TW name "hop"')
         rqlst = parse('WorkflowTransition C WHERE C subworkflow_exit EXIT')
         rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any C WHERE C subworkflow_exit EXIT, C is WorkflowTransition, "
-                             "EXISTS(C name 'hop'), EXIT is SubWorkflowExitPoint")
+                         "Any C WHERE C subworkflow_exit EXIT, C is WorkflowTransition, "
+                         "EXISTS(C name 'hop'), EXIT is SubWorkflowExitPoint")
 
     def test_relation_optimization_2_lhs(self):
         # optional relation can be shared if also optional in the snippet
@@ -273,15 +274,15 @@
         rqlst = parse('Card C WHERE C in_state STATE?')
         rewrite(rqlst, {('C', 'X'): (snippet,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any C WHERE C in_state STATE?, C is Card, "
-                             "EXISTS(STATE name 'hop'), STATE is State")
+                         "Any C WHERE C in_state STATE?, C is Card, "
+                         "EXISTS(STATE name 'hop'), STATE is State")
     def test_relation_optimization_2_rhs(self):
         snippet = ('TW? subworkflow_exit X, TW name "hop"')
         rqlst = parse('SubWorkflowExitPoint EXIT WHERE C? subworkflow_exit EXIT')
         rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any EXIT WHERE C? subworkflow_exit EXIT, EXIT is SubWorkflowExitPoint, "
-                             "EXISTS(C name 'hop'), C is WorkflowTransition")
+                         "Any EXIT WHERE C? subworkflow_exit EXIT, EXIT is SubWorkflowExitPoint, "
+                         "EXISTS(C name 'hop'), C is WorkflowTransition")
 
     def test_relation_optimization_3_lhs(self):
         # optional relation in the snippet but not in the orig tree can be shared
@@ -289,15 +290,15 @@
         rqlst = parse('Card C WHERE C in_state STATE')
         rewrite(rqlst, {('C', 'X'): (snippet,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any C WHERE C in_state STATE, C is Card, "
-                             "EXISTS(STATE name 'hop'), STATE is State")
+                         "Any C WHERE C in_state STATE, C is Card, "
+                         "EXISTS(STATE name 'hop'), STATE is State")
     def test_relation_optimization_3_rhs(self):
         snippet = ('TW? subworkflow_exit X, TW name "hop"')
         rqlst = parse('WorkflowTransition C WHERE C subworkflow_exit EXIT')
         rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any C WHERE C subworkflow_exit EXIT, C is WorkflowTransition, "
-                             "EXISTS(C name 'hop'), EXIT is SubWorkflowExitPoint")
+                         "Any C WHERE C subworkflow_exit EXIT, C is WorkflowTransition, "
+                         "EXISTS(C name 'hop'), EXIT is SubWorkflowExitPoint")
 
     def test_relation_non_optimization_1_lhs(self):
         # but optional relation in the orig tree but not in the snippet can't be shared
@@ -305,16 +306,16 @@
         rqlst = parse('Card C WHERE C in_state STATE?')
         rewrite(rqlst, {('C', 'X'): (snippet,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any C WHERE C in_state STATE?, C is Card, "
-                             "EXISTS(C in_state A, A name 'hop', A is State), STATE is State")
+                         "Any C WHERE C in_state STATE?, C is Card, "
+                         "EXISTS(C in_state A, A name 'hop', A is State), STATE is State")
     def test_relation_non_optimization_1_rhs(self):
         snippet = ('TW subworkflow_exit X, TW name "hop"')
         rqlst = parse('SubWorkflowExitPoint EXIT WHERE C? subworkflow_exit EXIT')
         rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             "Any EXIT WHERE C? subworkflow_exit EXIT, EXIT is SubWorkflowExitPoint, "
-                             "EXISTS(A subworkflow_exit EXIT, A name 'hop', A is WorkflowTransition), "
-                             "C is WorkflowTransition")
+                         "Any EXIT WHERE C? subworkflow_exit EXIT, EXIT is SubWorkflowExitPoint, "
+                         "EXISTS(A subworkflow_exit EXIT, A name 'hop', A is WorkflowTransition), "
+                         "C is WorkflowTransition")
 
     def test_unsupported_constraint_1(self):
         # CWUser doesn't have require_permission
@@ -327,8 +328,8 @@
         rqlst = parse('Any U,T WHERE U is CWUser, T wf_info_for U')
         rewrite(rqlst, {('T', 'X'): (trinfo_constraint, 'X wf_info_for Y, Y in_group G, G name "managers"')}, {})
         self.assertEqual(rqlst.as_string(),
-                             u"Any U,T WHERE U is CWUser, T wf_info_for U, "
-                             "EXISTS(U in_group B, B name 'managers', B is CWGroup), T is TrInfo")
+                         u"Any U,T WHERE U is CWUser, T wf_info_for U, "
+                         "EXISTS(U in_group B, B name 'managers', B is CWGroup), T is TrInfo")
 
     def test_unsupported_constraint_3(self):
         self.skipTest('raise unauthorized for now')
@@ -336,14 +337,14 @@
         rqlst = parse('Any T WHERE T wf_info_for X')
         rewrite(rqlst, {('T', 'X'): (trinfo_constraint, 'X in_group G, G name "managers"')}, {})
         self.assertEqual(rqlst.as_string(),
-                             u'XXX dunno what should be generated')
+                         u'XXX dunno what should be generated')
 
     def test_add_ambiguity_exists(self):
         constraint = ('X concerne Y')
         rqlst = parse('Affaire X')
         rewrite(rqlst, {('X', 'X'): (constraint,)}, {})
         self.assertEqual(rqlst.as_string(),
-                             u"Any X WHERE X is Affaire, ((EXISTS(X concerne A, A is Division)) OR (EXISTS(X concerne C, C is Societe))) OR (EXISTS(X concerne B, B is Note))")
+                         u"Any X WHERE X is Affaire, ((EXISTS(X concerne A, A is Division)) OR (EXISTS(X concerne C, C is Societe))) OR (EXISTS(X concerne B, B is Note))")
 
     def test_add_ambiguity_outerjoin(self):
         constraint = ('X concerne Y')
@@ -351,7 +352,7 @@
         rewrite(rqlst, {('X', 'X'): (constraint,)}, {})
         # ambiguity are kept in the sub-query, no need to be resolved using OR
         self.assertEqual(rqlst.as_string(),
-                             u"Any X,C WHERE X? documented_by C, C is Card WITH X BEING (Any X WHERE EXISTS(X concerne A), X is Affaire)")
+                         u"Any X,C WHERE X? documented_by C, C is Card WITH X BEING (Any X WHERE EXISTS(X concerne A), X is Affaire)")
 
 
     def test_rrqlexpr_nonexistant_subject_1(self):
@@ -359,76 +360,76 @@
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU')
         self.assertEqual(rqlst.as_string(),
-                             u"Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)")
+                         u"Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)")
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU')
         self.assertEqual(rqlst.as_string(),
-                             u"Any C WHERE C is Card")
+                         u"Any C WHERE C is Card")
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SOU')
         self.assertEqual(rqlst.as_string(),
-                             u"Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)")
+                         u"Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)")
 
     def test_rrqlexpr_nonexistant_subject_2(self):
         constraint = RRQLExpression('S owned_by U, O owned_by U, O is Card')
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU')
         self.assertEqual(rqlst.as_string(),
-                             'Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)')
+                         'Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)')
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU')
         self.assertEqual(rqlst.as_string(),
-                             'Any C WHERE C is Card, B eid %(D)s, EXISTS(A owned_by B, A is Card)')
+                         'Any C WHERE C is Card, B eid %(D)s, EXISTS(A owned_by B, A is Card)')
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SOU')
         self.assertEqual(rqlst.as_string(),
-                             'Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A, D owned_by A, D is Card)')
+                         'Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A, D owned_by A, D is Card)')
 
     def test_rrqlexpr_nonexistant_subject_3(self):
         constraint = RRQLExpression('U in_group G, G name "users"')
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU')
         self.assertEqual(rqlst.as_string(),
-                             u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", D is CWGroup)')
+                         u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", D is CWGroup)')
 
     def test_rrqlexpr_nonexistant_subject_4(self):
         constraint = RRQLExpression('U in_group G, G name "users", S owned_by U')
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU')
         self.assertEqual(rqlst.as_string(),
-                             u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", C owned_by A, D is CWGroup)')
+                         u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", C owned_by A, D is CWGroup)')
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU')
         self.assertEqual(rqlst.as_string(),
-                             u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", D is CWGroup)')
+                         u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", D is CWGroup)')
 
     def test_rrqlexpr_nonexistant_subject_5(self):
         constraint = RRQLExpression('S owned_by Z, O owned_by Z, O is Card')
         rqlst = parse('Card C')
         rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'S')
         self.assertEqual(rqlst.as_string(),
-                             u"Any C WHERE C is Card, EXISTS(C owned_by A, A is CWUser)")
+                         u"Any C WHERE C is Card, EXISTS(C owned_by A, A is CWUser)")
 
     def test_rqlexpr_not_relation_1_1(self):
         constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
         rqlst = parse('Affaire A WHERE NOT EXISTS(A documented_by C)')
         rewrite(rqlst, {('C', 'X'): (constraint,)}, {}, 'X')
         self.assertEqual(rqlst.as_string(),
-                             u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire')
+                         u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire')
 
     def test_rqlexpr_not_relation_1_2(self):
         constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
         rqlst = parse('Affaire A WHERE NOT EXISTS(A documented_by C)')
         rewrite(rqlst, {('A', 'X'): (constraint,)}, {}, 'X')
         self.assertEqual(rqlst.as_string(),
-                             u'Any A WHERE NOT EXISTS(A documented_by C, C is Card), A is Affaire, EXISTS(A owned_by B, B login "hop", B is CWUser)')
+                         u'Any A WHERE NOT EXISTS(A documented_by C, C is Card), A is Affaire, EXISTS(A owned_by B, B login "hop", B is CWUser)')
 
     def test_rqlexpr_not_relation_2(self):
         constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
         rqlst = rqlhelper.parse('Affaire A WHERE NOT A documented_by C', annotate=False)
         rewrite(rqlst, {('C', 'X'): (constraint,)}, {}, 'X')
         self.assertEqual(rqlst.as_string(),
-                             u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire')
+                         u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire')
 
 
 if __name__ == '__main__':