26 'B in_group P, P name "managers"') |
26 'B in_group P, P name "managers"') |
27 |
27 |
28 def test_1(self): |
28 def test_1(self): |
29 self.assertEquals(self._generate(self.select, 'in_state', 'subject', 'name'), |
29 self.assertEquals(self._generate(self.select, 'in_state', 'subject', 'name'), |
30 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
30 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
31 "B in_state A, A name C, B is EUser") |
31 "B in_state A, A name C, B is CWUser") |
32 |
32 |
33 def test_2(self): |
33 def test_2(self): |
34 self.assertEquals(self._generate(self.select, 'tags', 'object', 'name'), |
34 self.assertEquals(self._generate(self.select, 'tags', 'object', 'name'), |
35 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
35 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
36 "A tags B, A name C, B is EUser") |
36 "A tags B, A name C, B is CWUser") |
37 |
37 |
38 def test_3(self): |
38 def test_3(self): |
39 self.assertEquals(self._generate(self.select, 'created_by', 'subject', 'login'), |
39 self.assertEquals(self._generate(self.select, 'created_by', 'subject', 'login'), |
40 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
40 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
41 "B created_by A, A login C, B is EUser") |
41 "B created_by A, A login C, B is CWUser") |
42 |
42 |
43 def test_4(self): |
43 def test_4(self): |
44 self.assertEquals(self._generate(self.parse('Any X WHERE X is EUser'), 'created_by', 'subject', 'login'), |
44 self.assertEquals(self._generate(self.parse('Any X WHERE X is CWUser'), 'created_by', 'subject', 'login'), |
45 "DISTINCT Any A,B ORDERBY B WHERE X is EUser, X created_by A, A login B") |
45 "DISTINCT Any A,B ORDERBY B WHERE X is CWUser, X created_by A, A login B") |
46 |
46 |
47 def test_5(self): |
47 def test_5(self): |
48 self.assertEquals(self._generate(self.parse('Any X,L WHERE X is EUser, X login L'), 'created_by', 'subject', 'login'), |
48 self.assertEquals(self._generate(self.parse('Any X,L WHERE X is CWUser, X login L'), 'created_by', 'subject', 'login'), |
49 "DISTINCT Any A,B ORDERBY B WHERE X is EUser, X created_by A, A login B") |
49 "DISTINCT Any A,B ORDERBY B WHERE X is CWUser, X created_by A, A login B") |
50 |
50 |
51 def test_nonregr1(self): |
51 def test_nonregr1(self): |
52 select = self.parse('Any T,V WHERE T bookmarked_by V?, ' |
52 select = self.parse('Any T,V WHERE T bookmarked_by V?, ' |
53 'V in_state VS, VS name "published", T created_by U') |
53 'V in_state VS, VS name "published", T created_by U') |
54 self.assertEquals(self._generate(select, 'created_by', 'subject', 'login'), |
54 self.assertEquals(self._generate(select, 'created_by', 'subject', 'login'), |
55 "DISTINCT Any A,B ORDERBY B WHERE T created_by U, " |
55 "DISTINCT Any A,B ORDERBY B WHERE T created_by U, " |
56 "T created_by A, A login B, T is Bookmark") |
56 "T created_by A, A login B, T is Bookmark") |
57 |
57 |
58 def test_nonregr2(self): |
58 def test_nonregr2(self): |
59 #'DISTINCT Any X,TMP,N WHERE P name TMP, X version_of P, P is Project, X is Version, not X in_state S,S name "published", X num N ORDERBY TMP,N' |
59 #'DISTINCT Any X,TMP,N WHERE P name TMP, X version_of P, P is Project, X is Version, not X in_state S,S name "published", X num N ORDERBY TMP,N' |
60 select = self.parse('DISTINCT Any V,TN,L ORDERBY TN,L WHERE T nom TN, V connait T, T is Personne, V is EUser,' |
60 select = self.parse('DISTINCT Any V,TN,L ORDERBY TN,L WHERE T nom TN, V connait T, T is Personne, V is CWUser,' |
61 'NOT V in_state VS, VS name "published", V login L') |
61 'NOT V in_state VS, VS name "published", V login L') |
62 rschema = self.schema['connait'] |
62 rschema = self.schema['connait'] |
63 for s, o in rschema.iter_rdefs(): |
63 for s, o in rschema.iter_rdefs(): |
64 rschema.set_rproperty(s, o, 'cardinality', '++') |
64 rschema.set_rproperty(s, o, 'cardinality', '++') |
65 try: |
65 try: |
66 self.assertEquals(self._generate(select, 'in_state', 'subject', 'name'), |
66 self.assertEquals(self._generate(select, 'in_state', 'subject', 'name'), |
67 "DISTINCT Any A,B ORDERBY B WHERE V is EUser, " |
67 "DISTINCT Any A,B ORDERBY B WHERE V is CWUser, " |
68 "NOT V in_state VS, VS name 'published', " |
68 "NOT V in_state VS, VS name 'published', " |
69 "V in_state A, A name B") |
69 "V in_state A, A name B") |
70 finally: |
70 finally: |
71 for s, o in rschema.iter_rdefs(): |
71 for s, o in rschema.iter_rdefs(): |
72 rschema.set_rproperty(s, o, 'cardinality', '**') |
72 rschema.set_rproperty(s, o, 'cardinality', '**') |
73 |
73 |
74 def test_nonregr3(self): |
74 def test_nonregr3(self): |
75 #'DISTINCT Any X,TMP,N WHERE P name TMP, X version_of P, P is Project, X is Version, not X in_state S,S name "published", X num N ORDERBY TMP,N' |
75 #'DISTINCT Any X,TMP,N WHERE P name TMP, X version_of P, P is Project, X is Version, not X in_state S,S name "published", X num N ORDERBY TMP,N' |
76 select = self.parse('DISTINCT Any X, MAX(Y) GROUPBY X WHERE X is EUser, Y is Bookmark, X in_group A') |
76 select = self.parse('DISTINCT Any X, MAX(Y) GROUPBY X WHERE X is CWUser, Y is Bookmark, X in_group A') |
77 self.assertEquals(self._generate(select, 'in_group', 'subject', 'name'), |
77 self.assertEquals(self._generate(select, 'in_group', 'subject', 'name'), |
78 "DISTINCT Any B,C ORDERBY C WHERE X is EUser, X in_group B, B name C") |
78 "DISTINCT Any B,C ORDERBY C WHERE X is CWUser, X in_group B, B name C") |
79 |
79 |
80 |
80 |
81 if __name__ == '__main__': |
81 if __name__ == '__main__': |
82 from logilab.common.testlib import unittest_main |
82 from logilab.common.testlib import unittest_main |
83 unittest_main() |
83 unittest_main() |