server/test/unittest_querier.py
changeset 7791 31bb51ea5485
parent 7713 467c52ff9557
child 7907 08320697ca1a
--- a/server/test/unittest_querier.py	Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_querier.py	Wed Sep 14 09:11:50 2011 +0200
@@ -250,7 +250,7 @@
 
     def test_unknown_eid(self):
         # should return an empty result set
-        self.failIf(self.execute('Any X WHERE X eid 99999999'))
+        self.assertFalse(self.execute('Any X WHERE X eid 99999999'))
 
     def test_typed_eid(self):
         # should return an empty result set
@@ -418,8 +418,8 @@
         self.execute("SET X tags Y WHERE X eid %(t)s, Y eid %(g)s",
                      {'g': geid, 't': teid})
         rset = self.execute("Any GN,TN ORDERBY GN WHERE T? tags G, T name TN, G name GN")
-        self.failUnless(['users', 'tag'] in rset.rows)
-        self.failUnless(['activated', None] in rset.rows)
+        self.assertTrue(['users', 'tag'] in rset.rows)
+        self.assertTrue(['activated', None] in rset.rows)
         rset = self.execute("Any GN,TN ORDERBY GN WHERE T tags G?, T name TN, G name GN")
         self.assertEqual(rset.rows, [[None, 'tagbis'], ['users', 'tag']])
 
@@ -494,26 +494,26 @@
 
     def test_select_custom_aggregat_concat_string(self):
         rset = self.execute('Any GROUP_CONCAT(N) WHERE X is CWGroup, X name N')
-        self.failUnless(rset)
-        self.failUnlessEqual(sorted(rset[0][0].split(', ')), ['guests', 'managers',
+        self.assertTrue(rset)
+        self.assertEqual(sorted(rset[0][0].split(', ')), ['guests', 'managers',
                                                              'owners', 'users'])
 
     def test_select_custom_regproc_limit_size(self):
         rset = self.execute('Any TEXT_LIMIT_SIZE(N, 3) WHERE X is CWGroup, X name N, X name "managers"')
-        self.failUnless(rset)
-        self.failUnlessEqual(rset[0][0], 'man...')
+        self.assertTrue(rset)
+        self.assertEqual(rset[0][0], 'man...')
         self.execute("INSERT Basket X: X name 'bidule', X description '<b>hop hop</b>', X description_format 'text/html'")
         rset = self.execute('Any LIMIT_SIZE(D, DF, 3) WHERE X is Basket, X description D, X description_format DF')
-        self.failUnless(rset)
-        self.failUnlessEqual(rset[0][0], 'hop...')
+        self.assertTrue(rset)
+        self.assertEqual(rset[0][0], 'hop...')
 
     def test_select_regproc_orderby(self):
         rset = self.execute('DISTINCT Any X,N ORDERBY GROUP_SORT_VALUE(N) WHERE X is CWGroup, X name N, X name "managers"')
-        self.failUnlessEqual(len(rset), 1)
-        self.failUnlessEqual(rset[0][1], 'managers')
+        self.assertEqual(len(rset), 1)
+        self.assertEqual(rset[0][1], 'managers')
         rset = self.execute('Any X,N ORDERBY GROUP_SORT_VALUE(N) WHERE X is CWGroup, X name N, NOT U in_group X, U login "admin"')
-        self.failUnlessEqual(len(rset), 3)
-        self.failUnlessEqual(rset[0][1], 'owners')
+        self.assertEqual(len(rset), 3)
+        self.assertEqual(rset[0][1], 'owners')
 
     def test_select_aggregat_sort(self):
         rset = self.execute('Any G, COUNT(U) GROUPBY G ORDERBY 2 WHERE U in_group G')
@@ -619,7 +619,7 @@
         self.assertEqual(len(rset.rows), 2, rset.rows)
         biduleeids = [r[0] for r in rset.rows]
         rset = self.execute(u'Any N where NOT N has_text "bidüle"')
-        self.failIf([r[0] for r in rset.rows if r[0] in biduleeids])
+        self.assertFalse([r[0] for r in rset.rows if r[0] in biduleeids])
         # duh?
         rset = self.execute('Any X WHERE X has_text %(text)s', {'text': u'ça'})
 
@@ -757,7 +757,7 @@
 
     def test_select_explicit_eid(self):
         rset = self.execute('Any X,E WHERE X owned_by U, X eid E, U eid %(u)s', {'u': self.session.user.eid})
-        self.failUnless(rset)
+        self.assertTrue(rset)
         self.assertEqual(rset.description[0][1], 'Int')
 
 #     def test_select_rewritten_optional(self):
@@ -774,7 +774,7 @@
         rset = self.execute('Tag X WHERE X creation_date TODAY')
         self.assertEqual(len(rset.rows), 2)
         rset = self.execute('Any MAX(D) WHERE X is Tag, X creation_date D')
-        self.failUnless(isinstance(rset[0][0], datetime), (rset[0][0], type(rset[0][0])))
+        self.assertTrue(isinstance(rset[0][0], datetime), (rset[0][0], type(rset[0][0])))
 
     def test_today(self):
         self.execute("INSERT Tag X: X name 'bidule', X creation_date TODAY")
@@ -891,11 +891,11 @@
 
     def test_select_date_mathexp(self):
         rset = self.execute('Any X, TODAY - CD WHERE X is CWUser, X creation_date CD')
-        self.failUnless(rset)
-        self.failUnlessEqual(rset.description[0][1], 'Interval')
+        self.assertTrue(rset)
+        self.assertEqual(rset.description[0][1], 'Interval')
         eid, = self.execute("INSERT Personne X: X nom 'bidule'")[0]
         rset = self.execute('Any X, NOW - CD WHERE X is Personne, X creation_date CD')
-        self.failUnlessEqual(rset.description[0][1], 'Interval')
+        self.assertEqual(rset.description[0][1], 'Interval')
 
     def test_select_subquery_aggregat_1(self):
         # percent users by groups
@@ -1173,7 +1173,7 @@
         rset = self.execute('Any X, Y WHERE X travaille Y')
         self.assertEqual(len(rset.rows), 1)
         # test add of an existant relation but with NOT X rel Y protection
-        self.failIf(self.execute("SET X travaille Y WHERE X eid %(x)s, Y eid %(y)s,"
+        self.assertFalse(self.execute("SET X travaille Y WHERE X eid %(x)s, Y eid %(y)s,"
                                  "NOT X travaille Y",
                                  {'x': str(eid1), 'y': str(eid2)}))
 
@@ -1198,9 +1198,9 @@
         peid2 = self.execute("INSERT Personne Y: Y nom 'tutu'")[0][0]
         self.execute('SET P1 owned_by U, P2 owned_by U '
                      'WHERE P1 eid %s, P2 eid %s, U eid %s' % (peid1, peid2, ueid))
-        self.failUnless(self.execute('Any X WHERE X eid %s, X owned_by U, U eid %s'
+        self.assertTrue(self.execute('Any X WHERE X eid %s, X owned_by U, U eid %s'
                                        % (peid1, ueid)))
-        self.failUnless(self.execute('Any X WHERE X eid %s, X owned_by U, U eid %s'
+        self.assertTrue(self.execute('Any X WHERE X eid %s, X owned_by U, U eid %s'
                                        % (peid2, ueid)))
 
     def test_update_math_expr(self):