server/test/unittest_querier.py
branchstable
changeset 9312 88d40fbcc071
parent 9281 49a7392bb5b5
child 9331 c6f54ed6b60a
equal deleted inserted replaced
9311:8833ead6f3e4 9312:88d40fbcc071
   381 
   381 
   382     def test_select_6(self):
   382     def test_select_6(self):
   383         self.execute("INSERT Personne X: X nom 'bidule'")[0]
   383         self.execute("INSERT Personne X: X nom 'bidule'")[0]
   384         rset = self.execute('Any Y where X name TMP, Y nom in (TMP, "bidule")')
   384         rset = self.execute('Any Y where X name TMP, Y nom in (TMP, "bidule")')
   385         #self.assertEqual(rset.description, [('Personne',), ('Personne',)])
   385         #self.assertEqual(rset.description, [('Personne',), ('Personne',)])
   386         self.assert_(('Personne',) in rset.description)
   386         self.assertIn(('Personne',), rset.description)
   387         rset = self.execute('DISTINCT Any Y where X name TMP, Y nom in (TMP, "bidule")')
   387         rset = self.execute('DISTINCT Any Y where X name TMP, Y nom in (TMP, "bidule")')
   388         self.assert_(('Personne',) in rset.description)
   388         self.assertIn(('Personne',), rset.description)
   389 
   389 
   390     def test_select_not_attr(self):
   390     def test_select_not_attr(self):
   391         peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
   391         peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
   392         seid = self.execute("INSERT Societe X: X nom 'chouette'")[0][0]
   392         seid = self.execute("INSERT Societe X: X nom 'chouette'")[0][0]
   393         rset = self.execute('Personne X WHERE NOT X nom "bidule"')
   393         rset = self.execute('Personne X WHERE NOT X nom "bidule"')
   464         self.execute("INSERT Tag X: X name 'tagbis'")[0][0]
   464         self.execute("INSERT Tag X: X name 'tagbis'")[0][0]
   465         geid = self.execute("CWGroup G WHERE G name 'users'")[0][0]
   465         geid = self.execute("CWGroup G WHERE G name 'users'")[0][0]
   466         self.execute("SET X tags Y WHERE X eid %(t)s, Y eid %(g)s",
   466         self.execute("SET X tags Y WHERE X eid %(t)s, Y eid %(g)s",
   467                      {'g': geid, 't': teid})
   467                      {'g': geid, 't': teid})
   468         rset = self.execute("Any GN,TN ORDERBY GN WHERE T? tags G, T name TN, G name GN")
   468         rset = self.execute("Any GN,TN ORDERBY GN WHERE T? tags G, T name TN, G name GN")
   469         self.assertTrue(['users', 'tag'] in rset.rows)
   469         self.assertIn(['users', 'tag'], rset.rows)
   470         self.assertTrue(['activated', None] in rset.rows)
   470         self.assertIn(['activated', None], rset.rows)
   471         rset = self.execute("Any GN,TN ORDERBY GN WHERE T tags G?, T name TN, G name GN")
   471         rset = self.execute("Any GN,TN ORDERBY GN WHERE T tags G?, T name TN, G name GN")
   472         self.assertEqual(rset.rows, [[None, 'tagbis'], ['users', 'tag']])
   472         self.assertEqual(rset.rows, [[None, 'tagbis'], ['users', 'tag']])
   473 
   473 
   474     def test_select_not_inline_rel(self):
   474     def test_select_not_inline_rel(self):
   475         self.execute("INSERT Personne X: X nom 'bidule'")
   475         self.execute("INSERT Personne X: X nom 'bidule'")
   816 
   816 
   817     def test_today_bug(self):
   817     def test_today_bug(self):
   818         self.execute("INSERT Tag X: X name 'bidule', X creation_date NOW")
   818         self.execute("INSERT Tag X: X name 'bidule', X creation_date NOW")
   819         self.execute("INSERT Tag Y: Y name 'toto'")
   819         self.execute("INSERT Tag Y: Y name 'toto'")
   820         rset = self.execute("Any D WHERE X name in ('bidule', 'toto') , X creation_date D")
   820         rset = self.execute("Any D WHERE X name in ('bidule', 'toto') , X creation_date D")
   821         self.assert_(isinstance(rset.rows[0][0], datetime), rset.rows)
   821         self.assertIsInstance(rset.rows[0][0], datetime)
   822         rset = self.execute('Tag X WHERE X creation_date TODAY')
   822         rset = self.execute('Tag X WHERE X creation_date TODAY')
   823         self.assertEqual(len(rset.rows), 2)
   823         self.assertEqual(len(rset.rows), 2)
   824         rset = self.execute('Any MAX(D) WHERE X is Tag, X creation_date D')
   824         rset = self.execute('Any MAX(D) WHERE X is Tag, X creation_date D')
   825         self.assertTrue(isinstance(rset[0][0], datetime), (rset[0][0], type(rset[0][0])))
   825         self.assertIsInstance(rset[0][0], datetime)
   826 
   826 
   827     def test_today(self):
   827     def test_today(self):
   828         self.execute("INSERT Tag X: X name 'bidule', X creation_date TODAY")
   828         self.execute("INSERT Tag X: X name 'bidule', X creation_date TODAY")
   829         self.execute("INSERT Tag Y: Y name 'toto'")
   829         self.execute("INSERT Tag Y: Y name 'toto'")
   830         rset = self.execute('Tag X WHERE X creation_date TODAY')
   830         rset = self.execute('Tag X WHERE X creation_date TODAY')