105 affaire_constraints = ('X ref LIKE "PUBLIC%"', 'U in_group G, G name "public"') |
105 affaire_constraints = ('X ref LIKE "PUBLIC%"', 'U in_group G, G name "public"') |
106 kwargs = {'u':2} |
106 kwargs = {'u':2} |
107 rqlst = parse('Any S WHERE S documented_by C, C eid %(u)s') |
107 rqlst = parse('Any S WHERE S documented_by C, C eid %(u)s') |
108 rewrite(rqlst, {('C', 'X'): (card_constraint,), ('S', 'X'): affaire_constraints}, |
108 rewrite(rqlst, {('C', 'X'): (card_constraint,), ('S', 'X'): affaire_constraints}, |
109 kwargs) |
109 kwargs) |
110 self.assertTextEquals(rqlst.as_string(), |
110 self.assertMultiLineEqual(rqlst.as_string(), |
111 "Any S WHERE S documented_by C, C eid %(u)s, B eid %(D)s, " |
111 "Any S WHERE S documented_by C, C eid %(u)s, B eid %(D)s, " |
112 "EXISTS(C in_state A, B in_group E, F require_state A, " |
112 "EXISTS(C in_state A, B in_group E, F require_state A, " |
113 "F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission), " |
113 "F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission), " |
114 "(EXISTS(S ref LIKE 'PUBLIC%')) OR (EXISTS(B in_group G, G name 'public', G is CWGroup)), " |
114 "(EXISTS(S ref LIKE 'PUBLIC%')) OR (EXISTS(B in_group G, G name 'public', G is CWGroup)), " |
115 "S is Affaire") |
115 "S is Affaire") |
268 self.failUnlessEqual(rqlst.as_string(), |
268 self.failUnlessEqual(rqlst.as_string(), |
269 u"Any U,T WHERE U is CWUser, T wf_info_for U, " |
269 u"Any U,T WHERE U is CWUser, T wf_info_for U, " |
270 "EXISTS(U in_group B, B name 'managers', B is CWGroup), T is TrInfo") |
270 "EXISTS(U in_group B, B name 'managers', B is CWGroup), T is TrInfo") |
271 |
271 |
272 def test_unsupported_constraint_3(self): |
272 def test_unsupported_constraint_3(self): |
273 self.skip('raise unauthorized for now') |
273 self.skipTest('raise unauthorized for now') |
274 trinfo_constraint = ('X wf_info_for Y, Y require_permission P, P name "read"') |
274 trinfo_constraint = ('X wf_info_for Y, Y require_permission P, P name "read"') |
275 rqlst = parse('Any T WHERE T wf_info_for X') |
275 rqlst = parse('Any T WHERE T wf_info_for X') |
276 rewrite(rqlst, {('T', 'X'): (trinfo_constraint, 'X in_group G, G name "managers"')}, {}) |
276 rewrite(rqlst, {('T', 'X'): (trinfo_constraint, 'X in_group G, G name "managers"')}, {}) |
277 self.failUnlessEqual(rqlst.as_string(), |
277 self.failUnlessEqual(rqlst.as_string(), |
278 u'XXX dunno what should be generated') |
278 u'XXX dunno what should be generated') |