312 self.cards: {'X': s[2], 'S': s[2]}}, |
312 self.cards: {'X': s[2], 'S': s[2]}}, |
313 True) |
313 True) |
314 |
314 |
315 def test_simplified_var(self): |
315 def test_simplified_var(self): |
316 repo._type_source_cache[999999] = ('Note', 'cards', 999999, 'cards') |
316 repo._type_source_cache[999999] = ('Note', 'cards', 999999, 'cards') |
|
317 # need access to source since X table has to be accessed because of the outer join |
317 self._test('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR (X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s', |
318 self._test('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR (X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s', |
318 {'x': 999999, 'u': self.session.user.eid}, |
319 {'x': 999999, 'u': self.session.user.eid}, |
319 {self.system: {'P': s[0], 'G': s[0], 'X': s[0], |
320 {self.system: {'P': s[0], 'G': s[0], |
320 'require_permission': s[0], 'in_group': s[0], 'P': s[0], 'require_group': s[0], |
321 'require_permission': s[0], 'in_group': s[0], 'P': s[0], 'require_group': s[0], |
321 'u': s[0]}}, |
322 'u': s[0]}, |
322 False) |
323 self.cards: {'X': s[0]}}, |
|
324 True) |
323 |
325 |
324 def test_delete_relation1(self): |
326 def test_delete_relation1(self): |
325 ueid = self.session.user.eid |
327 ueid = self.session.user.eid |
326 self._test('Any X, Y WHERE X created_by Y, X eid %(x)s, NOT Y eid %(y)s', |
328 self._test('Any X, Y WHERE X created_by Y, X eid %(x)s, NOT Y eid %(y)s', |
327 {'x': ueid, 'y': ueid}, |
329 {'x': ueid, 'y': ueid}, |
1310 None, None, [self.system], |
1312 None, None, [self.system], |
1311 {'A': 'table0.C0', 'A.creation_date': 'table0.C1', 'A.modification_date': 'table0.C2', 'C': 'table0.C2', 'B': 'table0.C1'}, [])], |
1313 {'A': 'table0.C0', 'A.creation_date': 'table0.C1', 'A.modification_date': 'table0.C2', 'C': 'table0.C2', 'B': 'table0.C1'}, [])], |
1312 {'x': 999999}) |
1314 {'x': 999999}) |
1313 |
1315 |
1314 |
1316 |
1315 def test_simplified_var(self): |
1317 def test_simplified_var_1(self): |
1316 ueid = self.session.user.eid |
1318 ueid = self.session.user.eid |
1317 repo._type_source_cache[999999] = ('Note', 'cards', 999999, 'cards') |
1319 repo._type_source_cache[999999] = ('Note', 'cards', 999999, 'cards') |
1318 self._test('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR (X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s', |
1320 # need access to cards source since X table has to be accessed because of the outer join |
1319 [('OneFetchStep', [('Any %s WHERE %s in_group G, (G name IN("managers", "logilab")) OR (X require_permission P?, P name "bla", P require_group G), X eid 999999' % (ueid, ueid), |
1321 self._test('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR ' |
1320 [{'X': 'Note', 'G': 'CWGroup', 'P': 'CWPermission'}])], |
1322 '(X require_permission P?, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s', |
|
1323 [('FetchStep', |
|
1324 [('Any 999999', [{}])], [self.cards], |
|
1325 None, {u'%(x)s': 'table0.C0'}, []), |
|
1326 ('OneFetchStep', |
|
1327 [(u'Any 6 WHERE 6 in_group G, (G name IN("managers", "logilab")) OR ' |
|
1328 '(X require_permission P?, P name "bla", P require_group G), ' |
|
1329 'G is CWGroup, P is CWPermission, X is Note', |
|
1330 [{'G': 'CWGroup', 'P': 'CWPermission', 'X': 'Note'}])], |
|
1331 None, None, [self.system], {u'%(x)s': 'table0.C0'}, [])], |
|
1332 {'x': 999999, 'u': ueid}) |
|
1333 |
|
1334 def test_simplified_var_2(self): |
|
1335 ueid = self.session.user.eid |
|
1336 repo._type_source_cache[999999] = ('Note', 'cards', 999999, 'cards') |
|
1337 # no need access to source since X is invariant |
|
1338 self._test('Any U WHERE U in_group G, (G name IN ("managers", "logilab") OR ' |
|
1339 '(X require_permission P, P name "bla", P require_group G)), X eid %(x)s, U eid %(u)s', |
|
1340 [('OneFetchStep', [('Any %s WHERE %s in_group G, (G name IN("managers", "logilab")) OR (999999 require_permission P, P name "bla", P require_group G)' % (ueid, ueid), |
|
1341 [{'G': 'CWGroup', 'P': 'CWPermission'}])], |
1321 None, None, [self.system], {}, [])], |
1342 None, None, [self.system], {}, [])], |
1322 {'x': 999999, 'u': ueid}) |
1343 {'x': 999999, 'u': ueid}) |
1323 |
1344 |
1324 def test_has_text(self): |
1345 def test_has_text(self): |
1325 self._test('Card X WHERE X has_text "toto"', |
1346 self._test('Card X WHERE X has_text "toto"', |
2669 None, None, |
2690 None, None, |
2670 [self.system], {'X': 'table0.C0'}, []) |
2691 [self.system], {'X': 'table0.C0'}, []) |
2671 ]) |
2692 ]) |
2672 ]) |
2693 ]) |
2673 |
2694 |
|
2695 def test_remove_from_deleted_source_1(self): |
|
2696 self.repo._type_source_cache[999999] = ('Note', 'cards', 999999, 'cards') |
|
2697 self._test('Note X WHERE X eid 999999, NOT X cw_source Y', |
|
2698 [('OneFetchStep', |
|
2699 [('Any 999999 WHERE NOT EXISTS(999999 cw_source Y)', |
|
2700 [{'Y': 'CWSource'}])], |
|
2701 None, None, [self.system], {}, []) |
|
2702 ]) |
|
2703 |
|
2704 def test_remove_from_deleted_source_2(self): |
|
2705 self.repo._type_source_cache[999999] = ('Note', 'cards', 999999, 'cards') |
|
2706 self.repo._type_source_cache[999998] = ('Note', 'cards', 999998, 'cards') |
|
2707 self._test('Note X WHERE X eid IN (999998, 999999), NOT X cw_source Y', |
|
2708 [('FetchStep', |
|
2709 [('Any X WHERE X eid IN(999998, 999999), X is Note', |
|
2710 [{'X': 'Note'}])], |
|
2711 [self.cards], None, {'X': 'table0.C0'}, []), |
|
2712 ('OneFetchStep', |
|
2713 [('Any X WHERE NOT EXISTS(X cw_source Y, Y is CWSource), X is Note', |
|
2714 [{'X': 'Note', 'Y': 'CWSource'}])], |
|
2715 None, None, [self.system],{'X': 'table0.C0'}, []) |
|
2716 ]) |
|
2717 |
2674 |
2718 |
2675 class FakeVCSSource(AbstractSource): |
2719 class FakeVCSSource(AbstractSource): |
2676 uri = 'ccc' |
2720 uri = 'ccc' |
2677 support_entities = {'Card': True, 'Note': True} |
2721 support_entities = {'Card': True, 'Note': True} |
2678 support_relations = {'multisource_inlined_rel': True, |
2722 support_relations = {'multisource_inlined_rel': True, |