44 'B modification_date BMD, T? tags B, T name TN, ' |
44 'B modification_date BMD, T? tags B, T name TN, ' |
45 'V? bookmarked_by B, V title VN, B created_by U?, ' |
45 'V? bookmarked_by B, V title VN, B created_by U?, ' |
46 'B in_group P, P name "managers"') |
46 'B in_group P, P name "managers"') |
47 |
47 |
48 def test_1(self): |
48 def test_1(self): |
49 self.assertEquals(self._generate(self.select, 'in_state', 'subject', 'name'), |
49 self.assertEqual(self._generate(self.select, 'in_state', 'subject', 'name'), |
50 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
50 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
51 "B in_state A, B is CWUser, A name C") |
51 "B in_state A, B is CWUser, A name C") |
52 |
52 |
53 def test_2(self): |
53 def test_2(self): |
54 self.assertEquals(self._generate(self.select, 'tags', 'object', 'name'), |
54 self.assertEqual(self._generate(self.select, 'tags', 'object', 'name'), |
55 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
55 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
56 "A tags B, B is CWUser, A name C") |
56 "A tags B, B is CWUser, A name C") |
57 |
57 |
58 def test_3(self): |
58 def test_3(self): |
59 self.assertEquals(self._generate(self.select, 'created_by', 'subject', 'login'), |
59 self.assertEqual(self._generate(self.select, 'created_by', 'subject', 'login'), |
60 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
60 "DISTINCT Any A,C ORDERBY C WHERE B in_group P, P name 'managers', " |
61 "B created_by A, B is CWUser, A login C") |
61 "B created_by A, B is CWUser, A login C") |
62 |
62 |
63 def test_4(self): |
63 def test_4(self): |
64 self.assertEquals(self._generate(self.parse('Any X WHERE X is CWUser'), 'created_by', 'subject', 'login'), |
64 self.assertEqual(self._generate(self.parse('Any X WHERE X is CWUser'), 'created_by', 'subject', 'login'), |
65 "DISTINCT Any A,B ORDERBY B WHERE X is CWUser, X created_by A, A login B") |
65 "DISTINCT Any A,B ORDERBY B WHERE X is CWUser, X created_by A, A login B") |
66 |
66 |
67 def test_5(self): |
67 def test_5(self): |
68 self.assertEquals(self._generate(self.parse('Any X,L WHERE X is CWUser, X login L'), 'created_by', 'subject', 'login'), |
68 self.assertEqual(self._generate(self.parse('Any X,L WHERE X is CWUser, X login L'), 'created_by', 'subject', 'login'), |
69 "DISTINCT Any A,B ORDERBY B WHERE X is CWUser, X created_by A, A login B") |
69 "DISTINCT Any A,B ORDERBY B WHERE X is CWUser, X created_by A, A login B") |
70 |
70 |
71 def test_nonregr1(self): |
71 def test_nonregr1(self): |
72 select = self.parse('Any T,V WHERE T bookmarked_by V?, ' |
72 select = self.parse('Any T,V WHERE T bookmarked_by V?, ' |
73 'V in_state VS, VS name "published", T created_by U') |
73 'V in_state VS, VS name "published", T created_by U') |
74 self.assertEquals(self._generate(select, 'created_by', 'subject', 'login'), |
74 self.assertEqual(self._generate(select, 'created_by', 'subject', 'login'), |
75 "DISTINCT Any A,B ORDERBY B WHERE T created_by U, " |
75 "DISTINCT Any A,B ORDERBY B WHERE T created_by U, " |
76 "T created_by A, T is Bookmark, A login B") |
76 "T created_by A, T is Bookmark, A login B") |
77 |
77 |
78 def test_nonregr2(self): |
78 def test_nonregr2(self): |
79 #'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' |
79 #'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' |
81 'NOT V in_state VS, VS name "published", V login L') |
81 'NOT V in_state VS, VS name "published", V login L') |
82 rschema = self.schema['connait'] |
82 rschema = self.schema['connait'] |
83 for rdefs in rschema.rdefs.values(): |
83 for rdefs in rschema.rdefs.values(): |
84 rdefs.cardinality = '++' |
84 rdefs.cardinality = '++' |
85 try: |
85 try: |
86 self.assertEquals(self._generate(select, 'in_state', 'subject', 'name'), |
86 self.assertEqual(self._generate(select, 'in_state', 'subject', 'name'), |
87 "DISTINCT Any A,B ORDERBY B WHERE V is CWUser, " |
87 "DISTINCT Any A,B ORDERBY B WHERE V is CWUser, " |
88 "NOT EXISTS(V in_state VS), VS name 'published', " |
88 "NOT EXISTS(V in_state VS), VS name 'published', " |
89 "V in_state A, A name B") |
89 "V in_state A, A name B") |
90 finally: |
90 finally: |
91 for rdefs in rschema.rdefs.values(): |
91 for rdefs in rschema.rdefs.values(): |
92 rdefs.cardinality = '**' |
92 rdefs.cardinality = '**' |
93 |
93 |
94 def test_nonregr3(self): |
94 def test_nonregr3(self): |
95 #'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' |
95 #'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' |
96 select = self.parse('DISTINCT Any X, MAX(Y) GROUPBY X WHERE X is CWUser, Y is Bookmark, X in_group A') |
96 select = self.parse('DISTINCT Any X, MAX(Y) GROUPBY X WHERE X is CWUser, Y is Bookmark, X in_group A') |
97 self.assertEquals(self._generate(select, 'in_group', 'subject', 'name'), |
97 self.assertEqual(self._generate(select, 'in_group', 'subject', 'name'), |
98 "DISTINCT Any B,C ORDERBY C WHERE X is CWUser, X in_group B, B name C") |
98 "DISTINCT Any B,C ORDERBY C WHERE X is CWUser, X in_group B, B name C") |
99 |
99 |
100 |
100 |
101 if __name__ == '__main__': |
101 if __name__ == '__main__': |
102 from logilab.common.testlib import unittest_main |
102 from logilab.common.testlib import unittest_main |