--- a/server/test/unittest_querier.py Fri Sep 24 18:20:57 2010 +0200
+++ b/server/test/unittest_querier.py Fri Sep 24 18:20:59 2010 +0200
@@ -57,7 +57,7 @@
class MakeSchemaTC(TestCase):
def test_known_values(self):
solution = {'A': 'String', 'B': 'CWUser'}
- self.assertEquals(make_schema((Variable('A'), Variable('B')), solution,
+ self.assertEqual(make_schema((Variable('A'), Variable('B')), solution,
'table0', TYPEMAP),
('C0 text,C1 integer', {'A': 'table0.C0', 'B': 'table0.C1'}))
@@ -84,7 +84,7 @@
def test_preprocess_1(self):
reid = self.execute('Any X WHERE X is CWRType, X name "owned_by"')[0][0]
rqlst = self._prepare('Any COUNT(RDEF) WHERE RDEF relation_type X, X eid %(x)s', {'x': reid})
- self.assertEquals(rqlst.solutions, [{'RDEF': 'CWAttribute'}, {'RDEF': 'CWRelation'}])
+ self.assertEqual(rqlst.solutions, [{'RDEF': 'CWAttribute'}, {'RDEF': 'CWRelation'}])
def test_preprocess_2(self):
teid = self.execute("INSERT Tag X: X name 'tag'")[0][0]
@@ -94,7 +94,7 @@
rqlst = self._prepare('Any X WHERE E eid %(x)s, E tags X', {'x': teid})
# the query may be optimized, should keep only one solution
# (any one, etype will be discarded)
- self.assertEquals(len(rqlst.solutions), 1)
+ self.assertEqual(len(rqlst.solutions), 1)
def test_preprocess_security(self):
plan = self._prepare_plan('Any ETN,COUNT(X) GROUPBY ETN '
@@ -102,24 +102,24 @@
plan.session = self.user_groups_session('users')
union = plan.rqlst
plan.preprocess(union)
- self.assertEquals(len(union.children), 1)
- self.assertEquals(len(union.children[0].with_), 1)
+ self.assertEqual(len(union.children), 1)
+ self.assertEqual(len(union.children[0].with_), 1)
subq = union.children[0].with_[0].query
- self.assertEquals(len(subq.children), 3)
- self.assertEquals([t.as_string() for t in union.children[0].selection],
+ self.assertEqual(len(subq.children), 3)
+ self.assertEqual([t.as_string() for t in union.children[0].selection],
['ETN','COUNT(X)'])
- self.assertEquals([t.as_string() for t in union.children[0].groupby],
+ self.assertEqual([t.as_string() for t in union.children[0].groupby],
['ETN'])
partrqls = sorted(((rqlst.as_string(), rqlst.solutions) for rqlst in subq.children))
rql, solutions = partrqls[0]
- self.assertEquals(rql,
+ self.assertEqual(rql,
'Any ETN,X WHERE X is ET, ET name ETN, (EXISTS(X owned_by %(B)s))'
' OR ((((EXISTS(D concerne C?, C owned_by %(B)s, X identity D, C is Division, D is Affaire))'
' OR (EXISTS(H concerne G?, G owned_by %(B)s, G is SubDivision, X identity H, H is Affaire)))'
' OR (EXISTS(I concerne F?, F owned_by %(B)s, F is Societe, X identity I, I is Affaire)))'
' OR (EXISTS(J concerne E?, E owned_by %(B)s, E is Note, X identity J, J is Affaire)))'
', ET is CWEType, X is Affaire')
- self.assertEquals(solutions, [{'C': 'Division',
+ self.assertEqual(solutions, [{'C': 'Division',
'D': 'Affaire',
'E': 'Note',
'F': 'Societe',
@@ -130,8 +130,8 @@
'X': 'Affaire',
'ET': 'CWEType', 'ETN': 'String'}])
rql, solutions = partrqls[1]
- self.assertEquals(rql, 'Any ETN,X WHERE X is ET, ET name ETN, ET is CWEType, X is IN(BaseTransition, Bookmark, CWAttribute, CWCache, CWConstraint, CWConstraintType, CWEType, CWGroup, CWPermission, CWProperty, CWRType, CWRelation, CWUniqueTogetherConstraint, CWUser, Card, Comment, Division, Email, EmailAddress, EmailPart, EmailThread, ExternalUri, File, Folder, Note, Personne, RQLExpression, Societe, State, SubDivision, SubWorkflowExitPoint, Tag, TrInfo, Transition, Workflow, WorkflowTransition)')
- self.assertListEquals(sorted(solutions),
+ self.assertEqual(rql, 'Any ETN,X WHERE X is ET, ET name ETN, ET is CWEType, X is IN(BaseTransition, Bookmark, CWAttribute, CWCache, CWConstraint, CWConstraintType, CWEType, CWGroup, CWPermission, CWProperty, CWRType, CWRelation, CWUniqueTogetherConstraint, CWUser, Card, Comment, Division, Email, EmailAddress, EmailPart, EmailThread, ExternalUri, File, Folder, Note, Personne, RQLExpression, Societe, State, SubDivision, SubWorkflowExitPoint, Tag, TrInfo, Transition, Workflow, WorkflowTransition)')
+ self.assertListEqual(sorted(solutions),
sorted([{'X': 'BaseTransition', 'ETN': 'String', 'ET': 'CWEType'},
{'X': 'Bookmark', 'ETN': 'String', 'ET': 'CWEType'},
{'X': 'Card', 'ETN': 'String', 'ET': 'CWEType'},
@@ -169,10 +169,10 @@
{'X': 'Workflow', 'ETN': 'String', 'ET': 'CWEType'},
{'X': 'WorkflowTransition', 'ETN': 'String', 'ET': 'CWEType'}]))
rql, solutions = partrqls[2]
- self.assertEquals(rql,
+ self.assertEqual(rql,
'Any ETN,X WHERE X is ET, ET name ETN, EXISTS(X owned_by %(C)s), '
'ET is CWEType, X is Basket')
- self.assertEquals(solutions, [{'ET': 'CWEType',
+ self.assertEqual(solutions, [{'ET': 'CWEType',
'X': 'Basket',
'ETN': 'String',
}])
@@ -182,45 +182,45 @@
plan.session = self.user_groups_session('users')
union = plan.rqlst
plan.preprocess(union)
- self.assertEquals(len(union.children), 1)
- self.assertEquals(len(union.children[0].with_), 1)
+ self.assertEqual(len(union.children), 1)
+ self.assertEqual(len(union.children[0].with_), 1)
subq = union.children[0].with_[0].query
- self.assertEquals(len(subq.children), 3)
- self.assertEquals([t.as_string() for t in union.children[0].selection],
+ self.assertEqual(len(subq.children), 3)
+ self.assertEqual([t.as_string() for t in union.children[0].selection],
['MAX(X)'])
def test_preprocess_nonregr(self):
rqlst = self._prepare('Any S ORDERBY SI WHERE NOT S ecrit_par O, S para SI')
- self.assertEquals(len(rqlst.solutions), 1)
+ self.assertEqual(len(rqlst.solutions), 1)
def test_build_description(self):
# should return an empty result set
rset = self.execute('Any X WHERE X eid %(x)s', {'x': self.session.user.eid})
- self.assertEquals(rset.description[0][0], 'CWUser')
+ self.assertEqual(rset.description[0][0], 'CWUser')
rset = self.execute('Any 1')
- self.assertEquals(rset.description[0][0], 'Int')
+ self.assertEqual(rset.description[0][0], 'Int')
rset = self.execute('Any TRUE')
- self.assertEquals(rset.description[0][0], 'Boolean')
+ self.assertEqual(rset.description[0][0], 'Boolean')
rset = self.execute('Any "hop"')
- self.assertEquals(rset.description[0][0], 'String')
+ self.assertEqual(rset.description[0][0], 'String')
rset = self.execute('Any TODAY')
- self.assertEquals(rset.description[0][0], 'Date')
+ self.assertEqual(rset.description[0][0], 'Date')
rset = self.execute('Any NOW')
- self.assertEquals(rset.description[0][0], 'Datetime')
+ self.assertEqual(rset.description[0][0], 'Datetime')
rset = self.execute('Any %(x)s', {'x': 1})
- self.assertEquals(rset.description[0][0], 'Int')
+ self.assertEqual(rset.description[0][0], 'Int')
rset = self.execute('Any %(x)s', {'x': 1L})
- self.assertEquals(rset.description[0][0], 'Int')
+ self.assertEqual(rset.description[0][0], 'Int')
rset = self.execute('Any %(x)s', {'x': True})
- self.assertEquals(rset.description[0][0], 'Boolean')
+ self.assertEqual(rset.description[0][0], 'Boolean')
rset = self.execute('Any %(x)s', {'x': 1.0})
- self.assertEquals(rset.description[0][0], 'Float')
+ self.assertEqual(rset.description[0][0], 'Float')
rset = self.execute('Any %(x)s', {'x': datetime.now()})
- self.assertEquals(rset.description[0][0], 'Datetime')
+ self.assertEqual(rset.description[0][0], 'Datetime')
rset = self.execute('Any %(x)s', {'x': 'str'})
- self.assertEquals(rset.description[0][0], 'String')
+ self.assertEqual(rset.description[0][0], 'String')
rset = self.execute('Any %(x)s', {'x': u'str'})
- self.assertEquals(rset.description[0][0], 'String')
+ self.assertEqual(rset.description[0][0], 'String')
class QuerierTC(BaseQuerierTC):
@@ -244,46 +244,46 @@
{'data': Binary("xxx")})[0][0]
fdata = self.execute('Any D WHERE X data D, X eid %(x)s', {'x': feid})[0][0]
self.assertIsInstance(fdata, Binary)
- self.assertEquals(fdata.getvalue(), 'xxx')
+ self.assertEqual(fdata.getvalue(), 'xxx')
# selection queries tests #################################################
def test_select_1(self):
rset = self.execute('Any X ORDERBY X WHERE X is CWGroup')
result, descr = rset.rows, rset.description
- self.assertEquals(tuplify(result), [(1,), (2,), (3,), (4,)])
- self.assertEquals(descr, [('CWGroup',), ('CWGroup',), ('CWGroup',), ('CWGroup',)])
+ self.assertEqual(tuplify(result), [(1,), (2,), (3,), (4,)])
+ self.assertEqual(descr, [('CWGroup',), ('CWGroup',), ('CWGroup',), ('CWGroup',)])
def test_select_2(self):
rset = self.execute('Any X ORDERBY N WHERE X is CWGroup, X name N')
- self.assertEquals(tuplify(rset.rows), [(1,), (2,), (3,), (4,)])
- self.assertEquals(rset.description, [('CWGroup',), ('CWGroup',), ('CWGroup',), ('CWGroup',)])
+ self.assertEqual(tuplify(rset.rows), [(1,), (2,), (3,), (4,)])
+ self.assertEqual(rset.description, [('CWGroup',), ('CWGroup',), ('CWGroup',), ('CWGroup',)])
rset = self.execute('Any X ORDERBY N DESC WHERE X is CWGroup, X name N')
- self.assertEquals(tuplify(rset.rows), [(4,), (3,), (2,), (1,)])
+ self.assertEqual(tuplify(rset.rows), [(4,), (3,), (2,), (1,)])
def test_select_3(self):
rset = self.execute('Any N GROUPBY N WHERE X is CWGroup, X name N')
result, descr = rset.rows, rset.description
result.sort()
- self.assertEquals(tuplify(result), [('guests',), ('managers',), ('owners',), ('users',)])
- self.assertEquals(descr, [('String',), ('String',), ('String',), ('String',)])
+ self.assertEqual(tuplify(result), [('guests',), ('managers',), ('owners',), ('users',)])
+ self.assertEqual(descr, [('String',), ('String',), ('String',), ('String',)])
def test_select_is(self):
rset = self.execute('Any X, TN ORDERBY TN LIMIT 10 WHERE X is T, T name TN')
result, descr = rset.rows, rset.description
- self.assertEquals(result[0][1], descr[0][0])
+ self.assertEqual(result[0][1], descr[0][0])
def test_select_is_aggr(self):
rset = self.execute('Any TN, COUNT(X) GROUPBY TN ORDERBY 2 DESC WHERE X is T, T name TN')
result, descr = rset.rows, rset.description
- self.assertEquals(descr[0][0], 'String')
- self.assertEquals(descr[0][1], 'Int')
- self.assertEquals(result[0][0], 'CWRelation') # XXX may change as schema evolve
+ self.assertEqual(descr[0][0], 'String')
+ self.assertEqual(descr[0][1], 'Int')
+ self.assertEqual(result[0][0], 'CWRelation') # XXX may change as schema evolve
def test_select_groupby_orderby(self):
rset = self.execute('Any N GROUPBY N ORDERBY N WHERE X is CWGroup, X name N')
- self.assertEquals(tuplify(rset.rows), [('guests',), ('managers',), ('owners',), ('users',)])
- self.assertEquals(rset.description, [('String',), ('String',), ('String',), ('String',)])
+ self.assertEqual(tuplify(rset.rows), [('guests',), ('managers',), ('owners',), ('users',)])
+ self.assertEqual(rset.description, [('String',), ('String',), ('String',), ('String',)])
def test_select_complex_groupby(self):
rset = self.execute('Any N GROUPBY N WHERE X name N')
@@ -295,20 +295,20 @@
def test_select_complex_orderby(self):
rset1 = self.execute('Any N ORDERBY N WHERE X name N')
- self.assertEquals(sorted(rset1.rows), rset1.rows)
+ self.assertEqual(sorted(rset1.rows), rset1.rows)
rset = self.execute('Any N ORDERBY N LIMIT 5 OFFSET 1 WHERE X name N')
- self.assertEquals(rset.rows[0][0], rset1.rows[1][0])
- self.assertEquals(len(rset), 5)
+ self.assertEqual(rset.rows[0][0], rset1.rows[1][0])
+ self.assertEqual(len(rset), 5)
def test_select_5(self):
rset = self.execute('Any X, TMP ORDERBY TMP WHERE X name TMP, X is CWGroup')
- self.assertEquals(tuplify(rset.rows), [(1, 'guests',), (2, 'managers',), (3, 'owners',), (4, 'users',)])
- self.assertEquals(rset.description, [('CWGroup', 'String',), ('CWGroup', 'String',), ('CWGroup', 'String',), ('CWGroup', 'String',)])
+ self.assertEqual(tuplify(rset.rows), [(1, 'guests',), (2, 'managers',), (3, 'owners',), (4, 'users',)])
+ self.assertEqual(rset.description, [('CWGroup', 'String',), ('CWGroup', 'String',), ('CWGroup', 'String',), ('CWGroup', 'String',)])
def test_select_6(self):
self.execute("INSERT Personne X: X nom 'bidule'")[0]
rset = self.execute('Any Y where X name TMP, Y nom in (TMP, "bidule")')
- #self.assertEquals(rset.description, [('Personne',), ('Personne',)])
+ #self.assertEqual(rset.description, [('Personne',), ('Personne',)])
self.assert_(('Personne',) in rset.description)
rset = self.execute('DISTINCT Any Y where X name TMP, Y nom in (TMP, "bidule")')
self.assert_(('Personne',) in rset.description)
@@ -317,17 +317,17 @@
peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
seid = self.execute("INSERT Societe X: X nom 'chouette'")[0][0]
rset = self.execute('Personne X WHERE NOT X nom "bidule"')
- self.assertEquals(len(rset.rows), 0, rset.rows)
+ self.assertEqual(len(rset.rows), 0, rset.rows)
rset = self.execute('Personne X WHERE NOT X nom "bid"')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
self.execute("SET P travaille S WHERE P nom 'bidule', S nom 'chouette'")
rset = self.execute('Personne X WHERE NOT X travaille S')
- self.assertEquals(len(rset.rows), 0, rset.rows)
+ self.assertEqual(len(rset.rows), 0, rset.rows)
def test_select_is_in(self):
self.execute("INSERT Personne X: X nom 'bidule'")
self.execute("INSERT Societe X: X nom 'chouette'")
- self.assertEquals(len(self.execute("Any X WHERE X is IN (Personne, Societe)")),
+ self.assertEqual(len(self.execute("Any X WHERE X is IN (Personne, Societe)")),
2)
def test_select_not_rel(self):
@@ -336,9 +336,9 @@
self.execute("INSERT Personne X: X nom 'autre'")
self.execute("SET P travaille S WHERE P nom 'bidule', S nom 'chouette'")
rset = self.execute('Personne X WHERE NOT X travaille S')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
rset = self.execute('Personne X WHERE NOT X travaille S, S nom "chouette"')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
def test_select_nonregr_inlined(self):
self.execute("INSERT Note X: X para 'bidule'")
@@ -347,15 +347,15 @@
self.execute("SET X ecrit_par P WHERE X para 'bidule', P nom 'chouette'")
rset = self.execute('Any U,T ORDERBY T DESC WHERE U is CWUser, '
'N ecrit_par U, N type T')#, {'x': self.ueid})
- self.assertEquals(len(rset.rows), 0)
+ self.assertEqual(len(rset.rows), 0)
def test_select_nonregr_edition_not(self):
groupeids = set((1, 2, 3))
groupreadperms = set(r[0] for r in self.execute('Any Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), X read_permission Y'))
rset = self.execute('DISTINCT Any Y WHERE X is CWEType, X name "CWGroup", Y eid IN(1, 2, 3), NOT X read_permission Y')
- self.assertEquals(sorted(r[0] for r in rset.rows), sorted(groupeids - groupreadperms))
+ self.assertEqual(sorted(r[0] for r in rset.rows), sorted(groupeids - groupreadperms))
rset = self.execute('DISTINCT Any Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), NOT X read_permission Y')
- self.assertEquals(sorted(r[0] for r in rset.rows), sorted(groupeids - groupreadperms))
+ self.assertEqual(sorted(r[0] for r in rset.rows), sorted(groupeids - groupreadperms))
def test_select_outer_join(self):
peid1 = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
@@ -363,27 +363,27 @@
seid1 = self.execute("INSERT Societe X: X nom 'chouette'")[0][0]
seid2 = self.execute("INSERT Societe X: X nom 'chouetos'")[0][0]
rset = self.execute('Any X,S ORDERBY X WHERE X travaille S?')
- self.assertEquals(rset.rows, [[peid1, None], [peid2, None]])
+ self.assertEqual(rset.rows, [[peid1, None], [peid2, None]])
self.execute("SET P travaille S WHERE P nom 'bidule', S nom 'chouette'")
rset = self.execute('Any X,S ORDERBY X WHERE X travaille S?')
- self.assertEquals(rset.rows, [[peid1, seid1], [peid2, None]])
+ self.assertEqual(rset.rows, [[peid1, seid1], [peid2, None]])
rset = self.execute('Any S,X ORDERBY S WHERE X? travaille S')
- self.assertEquals(rset.rows, [[seid1, peid1], [seid2, None]])
+ self.assertEqual(rset.rows, [[seid1, peid1], [seid2, None]])
def test_select_outer_join_optimized(self):
peid1 = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
rset = self.execute('Any X WHERE X eid %(x)s, P? connait X', {'x':peid1})
- self.assertEquals(rset.rows, [[peid1]])
+ self.assertEqual(rset.rows, [[peid1]])
rset = self.execute('Any X WHERE X eid %(x)s, X require_permission P?',
{'x':peid1})
- self.assertEquals(rset.rows, [[peid1]])
+ self.assertEqual(rset.rows, [[peid1]])
def test_select_left_outer_join(self):
rset = self.execute('DISTINCT Any G WHERE U? in_group G')
- self.assertEquals(len(rset), 4)
+ self.assertEqual(len(rset), 4)
rset = self.execute('DISTINCT Any G WHERE U? in_group G, U eid %(x)s',
{'x': self.session.user.eid})
- self.assertEquals(len(rset), 4)
+ self.assertEqual(len(rset), 4)
def test_select_ambigous_outer_join(self):
teid = self.execute("INSERT Tag X: X name 'tag'")[0][0]
@@ -395,7 +395,7 @@
self.failUnless(['users', 'tag'] in rset.rows)
self.failUnless(['activated', None] in rset.rows)
rset = self.execute("Any GN,TN ORDERBY GN WHERE T tags G?, T name TN, G name GN")
- self.assertEquals(rset.rows, [[None, 'tagbis'], ['users', 'tag']])
+ self.assertEqual(rset.rows, [[None, 'tagbis'], ['users', 'tag']])
def test_select_not_inline_rel(self):
self.execute("INSERT Personne X: X nom 'bidule'")
@@ -403,7 +403,7 @@
self.execute("INSERT Note X: X type 'b'")
self.execute("SET X ecrit_par Y WHERE X type 'a', Y nom 'bidule'")
rset = self.execute('Note X WHERE NOT X ecrit_par P')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
def test_select_not_unlinked_multiple_solutions(self):
self.execute("INSERT Personne X: X nom 'bidule'")
@@ -411,7 +411,7 @@
self.execute("INSERT Note X: X type 'b'")
self.execute("SET Y evaluee X WHERE X type 'a', Y nom 'bidule'")
rset = self.execute('Note X WHERE NOT Y evaluee X')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
def test_select_date_extraction(self):
self.execute("INSERT Personne X: X nom 'foo', X datenaiss %(d)s",
@@ -421,41 +421,41 @@
for funcname, result in test_data:
rset = self.execute('Any %s(D) WHERE X is Personne, X datenaiss D'
% funcname)
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(rset.rows[0][0], result)
- self.assertEquals(rset.description, [('Int',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(rset.rows[0][0], result)
+ self.assertEqual(rset.description, [('Int',)])
def test_select_aggregat_count(self):
rset = self.execute('Any COUNT(X)')
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(len(rset.rows[0]), 1)
- self.assertEquals(rset.description, [('Int',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(len(rset.rows[0]), 1)
+ self.assertEqual(rset.description, [('Int',)])
def test_select_aggregat_sum(self):
rset = self.execute('Any SUM(O) WHERE X ordernum O')
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(len(rset.rows[0]), 1)
- self.assertEquals(rset.description, [('Int',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(len(rset.rows[0]), 1)
+ self.assertEqual(rset.description, [('Int',)])
def test_select_aggregat_min(self):
rset = self.execute('Any MIN(X) WHERE X is Personne')
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(len(rset.rows[0]), 1)
- self.assertEquals(rset.description, [('Personne',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(len(rset.rows[0]), 1)
+ self.assertEqual(rset.description, [('Personne',)])
rset = self.execute('Any MIN(O) WHERE X ordernum O')
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(len(rset.rows[0]), 1)
- self.assertEquals(rset.description, [('Int',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(len(rset.rows[0]), 1)
+ self.assertEqual(rset.description, [('Int',)])
def test_select_aggregat_max(self):
rset = self.execute('Any MAX(X) WHERE X is Personne')
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(len(rset.rows[0]), 1)
- self.assertEquals(rset.description, [('Personne',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(len(rset.rows[0]), 1)
+ self.assertEqual(rset.description, [('Personne',)])
rset = self.execute('Any MAX(O) WHERE X ordernum O')
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(len(rset.rows[0]), 1)
- self.assertEquals(rset.description, [('Int',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(len(rset.rows[0]), 1)
+ self.assertEqual(rset.description, [('Int',)])
def test_select_custom_aggregat_concat_string(self):
rset = self.execute('Any GROUP_CONCAT(N) WHERE X is CWGroup, X name N')
@@ -482,15 +482,15 @@
def test_select_aggregat_sort(self):
rset = self.execute('Any G, COUNT(U) GROUPBY G ORDERBY 2 WHERE U in_group G')
- self.assertEquals(len(rset.rows), 2)
- self.assertEquals(len(rset.rows[0]), 2)
- self.assertEquals(rset.description[0], ('CWGroup', 'Int',))
+ self.assertEqual(len(rset.rows), 2)
+ self.assertEqual(len(rset.rows[0]), 2)
+ self.assertEqual(rset.description[0], ('CWGroup', 'Int',))
def test_select_aggregat_having(self):
rset = self.execute('Any N,COUNT(RDEF) GROUPBY N ORDERBY 2,N '
'WHERE RT name N, RDEF relation_type RT '
'HAVING COUNT(RDEF) > 10')
- self.assertListEquals(rset.rows,
+ self.assertListEqual(rset.rows,
[[u'description_format', 12],
[u'description', 13],
[u'name', 14],
@@ -508,13 +508,13 @@
rset = self.execute('Any U,COUNT(X) GROUPBY U '
'WHERE U eid %(x)s, X owned_by U '
'HAVING COUNT(X) > 10', {'x': self.ueid})
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(rset.rows[0][0], self.ueid)
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(rset.rows[0][0], self.ueid)
def test_select_having_non_aggregat_1(self):
rset = self.execute('Any L WHERE X login L, X creation_date CD '
'HAVING YEAR(CD) = %s' % date.today().year)
- self.assertListEquals(rset.rows,
+ self.assertListEqual(rset.rows,
[[u'admin'],
[u'anon']])
@@ -522,7 +522,7 @@
rset = self.execute('Any L GROUPBY L WHERE X login L, X in_group G, '
'X creation_date CD HAVING YEAR(CD) = %s OR COUNT(G) > 1'
% date.today().year)
- self.assertListEquals(rset.rows,
+ self.assertListEqual(rset.rows,
[[u'admin'],
[u'anon']])
@@ -531,26 +531,26 @@
rset = self.execute('Any X ORDERBY X,D LIMIT 5 WHERE X creation_date D')
result = rset.rows
result.sort()
- self.assertEquals(tuplify(result), [(1,), (2,), (3,), (4,), (5,)])
+ self.assertEqual(tuplify(result), [(1,), (2,), (3,), (4,), (5,)])
def test_select_upper(self):
rset = self.execute('Any X, UPPER(L) ORDERBY L WHERE X is CWUser, X login L')
- self.assertEquals(len(rset.rows), 2)
- self.assertEquals(rset.rows[0][1], 'ADMIN')
- self.assertEquals(rset.description[0], ('CWUser', 'String',))
- self.assertEquals(rset.rows[1][1], 'ANON')
- self.assertEquals(rset.description[1], ('CWUser', 'String',))
+ self.assertEqual(len(rset.rows), 2)
+ self.assertEqual(rset.rows[0][1], 'ADMIN')
+ self.assertEqual(rset.description[0], ('CWUser', 'String',))
+ self.assertEqual(rset.rows[1][1], 'ANON')
+ self.assertEqual(rset.description[1], ('CWUser', 'String',))
eid = rset.rows[0][0]
rset = self.execute('Any UPPER(L) WHERE X eid %s, X login L'%eid)
- self.assertEquals(rset.rows[0][0], 'ADMIN')
- self.assertEquals(rset.description, [('String',)])
+ self.assertEqual(rset.rows[0][0], 'ADMIN')
+ self.assertEqual(rset.description, [('String',)])
## def test_select_simplified(self):
## ueid = self.session.user.eid
## rset = self.execute('Any L WHERE %s login L'%ueid)
-## self.assertEquals(rset.rows[0][0], 'admin')
+## self.assertEqual(rset.rows[0][0], 'admin')
## rset = self.execute('Any L WHERE %(x)s login L', {'x':ueid})
-## self.assertEquals(rset.rows[0][0], 'admin')
+## self.assertEqual(rset.rows[0][0], 'admin')
def test_select_searchable_text_1(self):
rset = self.execute(u"INSERT Personne X: X nom 'bidüle'")
@@ -558,9 +558,9 @@
rset = self.execute("INSERT Societe X: X nom 'chouette'")
self.commit()
rset = self.execute('Any X where X has_text %(text)s', {'text': u'bidüle'})
- self.assertEquals(len(rset.rows), 2, rset.rows)
+ self.assertEqual(len(rset.rows), 2, rset.rows)
rset = self.execute(u'Any N where N has_text "bidüle"')
- self.assertEquals(len(rset.rows), 2, rset.rows)
+ 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])
@@ -573,7 +573,7 @@
rset = self.execute("INSERT Societe X: X nom 'bidule'")
self.commit()
rset = self.execute('Personne N where N has_text "bidule"')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
def test_select_searchable_text_3(self):
rset = self.execute("INSERT Personne X: X nom 'bidule', X sexe 'M'")
@@ -581,7 +581,7 @@
rset = self.execute("INSERT Societe X: X nom 'bidule'")
self.commit()
rset = self.execute('Any X where X has_text "bidule" and X sexe "M"')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
def test_select_multiple_searchable_text(self):
self.execute(u"INSERT Personne X: X nom 'bidüle'")
@@ -592,20 +592,20 @@
{'text': u'bidüle',
'text2': u'chouette',}
)
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
def test_select_no_descr(self):
rset = self.execute('Any X WHERE X is CWGroup', build_descr=0)
rset.rows.sort()
- self.assertEquals(tuplify(rset.rows), [(1,), (2,), (3,), (4,)])
- self.assertEquals(rset.description, ())
+ self.assertEqual(tuplify(rset.rows), [(1,), (2,), (3,), (4,)])
+ self.assertEqual(rset.description, ())
def test_select_limit_offset(self):
rset = self.execute('CWGroup X ORDERBY N LIMIT 2 WHERE X name N')
- self.assertEquals(tuplify(rset.rows), [(1,), (2,)])
- self.assertEquals(rset.description, [('CWGroup',), ('CWGroup',)])
+ self.assertEqual(tuplify(rset.rows), [(1,), (2,)])
+ self.assertEqual(rset.description, [('CWGroup',), ('CWGroup',)])
rset = self.execute('CWGroup X ORDERBY N LIMIT 2 OFFSET 2 WHERE X name N')
- self.assertEquals(tuplify(rset.rows), [(3,), (4,)])
+ self.assertEqual(tuplify(rset.rows), [(3,), (4,)])
def test_select_symmetric(self):
self.execute("INSERT Personne X: X nom 'machin'")
@@ -615,24 +615,24 @@
self.execute("SET X connait Y WHERE X nom 'chouette', Y nom 'bidule'")
self.execute("SET X connait Y WHERE X nom 'machin', Y nom 'chouette'")
rset = self.execute('Any P where P connait P2')
- self.assertEquals(len(rset.rows), 3, rset.rows)
+ self.assertEqual(len(rset.rows), 3, rset.rows)
rset = self.execute('Any P where NOT P connait P2')
- self.assertEquals(len(rset.rows), 1, rset.rows) # trucmuche
+ self.assertEqual(len(rset.rows), 1, rset.rows) # trucmuche
rset = self.execute('Any P where P connait P2, P2 nom "bidule"')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
rset = self.execute('Any P where P2 connait P, P2 nom "bidule"')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
rset = self.execute('Any P where P connait P2, P2 nom "chouette"')
- self.assertEquals(len(rset.rows), 2, rset.rows)
+ self.assertEqual(len(rset.rows), 2, rset.rows)
rset = self.execute('Any P where P2 connait P, P2 nom "chouette"')
- self.assertEquals(len(rset.rows), 2, rset.rows)
+ self.assertEqual(len(rset.rows), 2, rset.rows)
def test_select_inline(self):
self.execute("INSERT Personne X: X nom 'bidule'")
self.execute("INSERT Note X: X type 'a'")
self.execute("SET X ecrit_par Y WHERE X type 'a', Y nom 'bidule'")
rset = self.execute('Any N where N ecrit_par X, X nom "bidule"')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
def test_select_creation_date(self):
self.execute("INSERT Personne X: X nom 'bidule'")
@@ -702,13 +702,13 @@
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.assertEquals(rset.description[0][1], 'Int')
+ self.assertEqual(rset.description[0][1], 'Int')
# def test_select_rewritten_optional(self):
# eid = self.execute("INSERT Affaire X: X sujet 'cool'")[0][0]
# rset = self.execute('Any X WHERE X eid %(x)s, EXISTS(X owned_by U) OR EXISTS(X concerne S?, S owned_by U)',
# {'x': eid}, 'x')
-# self.assertEquals(rset.rows, [[eid]])
+# self.assertEqual(rset.rows, [[eid]])
def test_today_bug(self):
self.execute("INSERT Tag X: X name 'bidule', X creation_date NOW")
@@ -729,14 +729,14 @@
def test_select_boolean(self):
rset = self.execute('Any N WHERE X is CWEType, X name N, X final %(val)s',
{'val': True})
- self.assertEquals(sorted(r[0] for r in rset.rows), ['Boolean', 'Bytes',
+ self.assertEqual(sorted(r[0] for r in rset.rows), ['Boolean', 'Bytes',
'Date', 'Datetime',
'Decimal', 'Float',
'Int', 'Interval',
'Password', 'String',
'Time'])
rset = self.execute('Any N WHERE X is CWEType, X name N, X final TRUE')
- self.assertEquals(sorted(r[0] for r in rset.rows), ['Boolean', 'Bytes',
+ self.assertEqual(sorted(r[0] for r in rset.rows), ['Boolean', 'Bytes',
'Date', 'Datetime',
'Decimal', 'Float',
'Int', 'Interval',
@@ -745,17 +745,17 @@
def test_select_constant(self):
rset = self.execute('Any X, "toto" ORDERBY X WHERE X is CWGroup')
- self.assertEquals(rset.rows,
+ self.assertEqual(rset.rows,
map(list, zip((1,2,3,4), ('toto','toto','toto','toto',))))
self.assertIsInstance(rset[0][1], unicode)
- self.assertEquals(rset.description,
+ self.assertEqual(rset.description,
zip(('CWGroup', 'CWGroup', 'CWGroup', 'CWGroup'),
('String', 'String', 'String', 'String',)))
rset = self.execute('Any X, %(value)s ORDERBY X WHERE X is CWGroup', {'value': 'toto'})
- self.assertEquals(rset.rows,
+ self.assertEqual(rset.rows,
map(list, zip((1,2,3,4), ('toto','toto','toto','toto',))))
self.assertIsInstance(rset[0][1], unicode)
- self.assertEquals(rset.description,
+ self.assertEqual(rset.description,
zip(('CWGroup', 'CWGroup', 'CWGroup', 'CWGroup'),
('String', 'String', 'String', 'String',)))
rset = self.execute('Any X,GN WHERE X is CWUser, G is CWGroup, X login "syt", X in_group G, G name GN')
@@ -766,9 +766,9 @@
' UNION '
'(Any X,N WHERE X name N, X state_of WF, WF workflow_of E, E name %(name)s))',
{'name': 'CWUser'})
- self.assertEquals([x[1] for x in rset.rows],
+ self.assertEqual([x[1] for x in rset.rows],
['activate', 'activated', 'deactivate', 'deactivated'])
- self.assertEquals(rset.description,
+ self.assertEqual(rset.description,
[('Transition', 'String'), ('State', 'String'),
('Transition', 'String'), ('State', 'String')])
@@ -788,13 +788,13 @@
'((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)'
' UNION '
'(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))')
- self.assertEquals(rset.rows, [[u'hop', 2], [u'hop', 2]])
+ self.assertEqual(rset.rows, [[u'hop', 2], [u'hop', 2]])
def test_select_union_selection_with_diff_variables(self):
rset = self.execute('(Any N WHERE X name N, X is State)'
' UNION '
'(Any NN WHERE XX name NN, XX is Transition)')
- self.assertEquals(sorted(r[0] for r in rset.rows),
+ self.assertEqual(sorted(r[0] for r in rset.rows),
['abort', 'activate', 'activated', 'ben non',
'deactivate', 'deactivated', 'done', 'en cours',
'end', 'finie', 'markasdone', 'pitetre', 'redoit',
@@ -807,7 +807,7 @@
' UNION '
'(Any Y WHERE Y eid %(y)s)',
{'x': eid1, 'y': eid2})
- self.assertEquals(rset.description[:], [('CWGroup',), ('CWUser',)])
+ self.assertEqual(rset.description[:], [('CWGroup',), ('CWUser',)])
def test_exists(self):
geid = self.execute("INSERT CWGroup X: X name 'lulufanclub'")[0][0]
@@ -815,15 +815,15 @@
peid = self.execute("INSERT Personne X: X prenom 'lulu', X nom 'petit'")[0][0]
rset = self.execute("Any X WHERE X prenom 'lulu',"
"EXISTS (U in_group G, G name 'lulufanclub' OR G name 'managers');")
- self.assertEquals(rset.rows, [[peid]])
+ self.assertEqual(rset.rows, [[peid]])
def test_identity(self):
eid = self.execute('Any X WHERE X identity Y, Y eid 1')[0][0]
- self.assertEquals(eid, 1)
+ self.assertEqual(eid, 1)
eid = self.execute('Any X WHERE Y identity X, Y eid 1')[0][0]
- self.assertEquals(eid, 1)
+ self.assertEqual(eid, 1)
login = self.execute('Any L WHERE X login "admin", X identity Y, Y login L')[0][0]
- self.assertEquals(login, 'admin')
+ self.assertEqual(login, 'admin')
def test_select_date_mathexp(self):
rset = self.execute('Any X, TODAY - CD WHERE X is CWUser, X creation_date CD')
@@ -839,8 +839,8 @@
rset = self.execute('Any GN, COUNT(X)*100/T GROUPBY GN ORDERBY 2,1'
' WHERE G name GN, X in_group G'
' WITH T BEING (Any COUNT(U) WHERE U is CWUser)')
- self.assertEquals(rset.rows, [[u'guests', 50], [u'managers', 50], [u'users', 100]])
- self.assertEquals(rset.description, [('String', 'Int'), ('String', 'Int'), ('String', 'Int')])
+ self.assertEqual(rset.rows, [[u'guests', 50], [u'managers', 50], [u'users', 100]])
+ self.assertEqual(rset.description, [('String', 'Int'), ('String', 'Int'), ('String', 'Int')])
def test_select_subquery_aggregat_2(self):
expected = self.execute('Any X, 0, COUNT(T) GROUPBY X '
@@ -851,55 +851,55 @@
T? transition_of P, T type "auto"),
P2,E BEING (Any P,COUNT(T) GROUPBY P WHERE P is Workflow, T is Transition,
T? transition_of P, T type "normal")''')
- self.assertEquals(sorted(rset.rows), sorted(expected))
+ self.assertEqual(sorted(rset.rows), sorted(expected))
def test_select_subquery_const(self):
rset = self.execute('Any X WITH X BEING ((Any NULL) UNION (Any "toto"))')
- self.assertEquals(rset.rows, [[None], ['toto']])
- self.assertEquals(rset.description, [(None,), ('String',)])
+ self.assertEqual(rset.rows, [[None], ['toto']])
+ self.assertEqual(rset.description, [(None,), ('String',)])
# insertion queries tests #################################################
def test_insert_is(self):
eid, = self.execute("INSERT Personne X: X nom 'bidule'")[0]
etype, = self.execute("Any TN WHERE X is T, X eid %s, T name TN" % eid)[0]
- self.assertEquals(etype, 'Personne')
+ self.assertEqual(etype, 'Personne')
self.execute("INSERT Personne X: X nom 'managers'")
def test_insert_1(self):
rset = self.execute("INSERT Personne X: X nom 'bidule'")
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(rset.description, [('Personne',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(rset.description, [('Personne',)])
rset = self.execute('Personne X WHERE X nom "bidule"')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne',)])
+ self.assertEqual(rset.description, [('Personne',)])
def test_insert_1_multiple(self):
self.execute("INSERT Personne X: X nom 'bidule'")
self.execute("INSERT Personne X: X nom 'chouette'")
rset = self.execute("INSERT Societe Y: Y nom N, P travaille Y WHERE P nom N")
- self.assertEquals(len(rset.rows), 2)
- self.assertEquals(rset.description, [('Societe',), ('Societe',)])
+ self.assertEqual(len(rset.rows), 2)
+ self.assertEqual(rset.description, [('Societe',), ('Societe',)])
def test_insert_2(self):
rset = self.execute("INSERT Personne X, Personne Y: X nom 'bidule', Y nom 'tutu'")
- self.assertEquals(rset.description, [('Personne', 'Personne')])
+ self.assertEqual(rset.description, [('Personne', 'Personne')])
rset = self.execute('Personne X WHERE X nom "bidule" or X nom "tutu"')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne',), ('Personne',)])
+ self.assertEqual(rset.description, [('Personne',), ('Personne',)])
def test_insert_3(self):
self.execute("INSERT Personne X: X nom Y WHERE U login 'admin', U login Y")
rset = self.execute('Personne X WHERE X nom "admin"')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne',)])
+ self.assertEqual(rset.description, [('Personne',)])
def test_insert_4(self):
self.execute("INSERT Societe Y: Y nom 'toto'")
self.execute("INSERT Personne X: X nom 'bidule', X travaille Y WHERE Y nom 'toto'")
rset = self.execute('Any X, Y WHERE X nom "bidule", Y nom "toto", X travaille Y')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne', 'Societe',)])
+ self.assertEqual(rset.description, [('Personne', 'Societe',)])
def test_insert_4bis(self):
peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
@@ -924,7 +924,7 @@
self.execute("INSERT Societe Y: Y nom 'toto', X travaille Y WHERE X nom 'bidule'")
rset = self.execute('Any X, Y WHERE X nom "bidule", Y nom "toto", X travaille Y')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne', 'Societe',)])
+ self.assertEqual(rset.description, [('Personne', 'Societe',)])
def test_insert_5bis(self):
peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
@@ -932,45 +932,45 @@
{'x': peid})
rset = self.execute('Any X, Y WHERE X nom "bidule", Y nom "toto", X travaille Y')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne', 'Societe',)])
+ self.assertEqual(rset.description, [('Personne', 'Societe',)])
def test_insert_6(self):
self.execute("INSERT Personne X, Societe Y: X nom 'bidule', Y nom 'toto', X travaille Y")
rset = self.execute('Any X, Y WHERE X nom "bidule", Y nom "toto", X travaille Y')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne', 'Societe',)])
+ self.assertEqual(rset.description, [('Personne', 'Societe',)])
def test_insert_7(self):
self.execute("INSERT Personne X, Societe Y: X nom N, Y nom 'toto', X travaille Y WHERE U login 'admin', U login N")
rset = self.execute('Any X, Y WHERE X nom "admin", Y nom "toto", X travaille Y')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne', 'Societe',)])
+ self.assertEqual(rset.description, [('Personne', 'Societe',)])
def test_insert_7_2(self):
self.execute("INSERT Personne X, Societe Y: X nom N, Y nom 'toto', X travaille Y WHERE U login N")
rset = self.execute('Any X, Y WHERE Y nom "toto", X travaille Y')
- self.assertEquals(len(rset), 2)
- self.assertEquals(rset.description, [('Personne', 'Societe',),
+ self.assertEqual(len(rset), 2)
+ self.assertEqual(rset.description, [('Personne', 'Societe',),
('Personne', 'Societe',)])
def test_insert_8(self):
self.execute("INSERT Societe Y, Personne X: Y nom N, X nom 'toto', X travaille Y WHERE U login 'admin', U login N")
rset = self.execute('Any X, Y WHERE X nom "toto", Y nom "admin", X travaille Y')
self.assert_(rset.rows)
- self.assertEquals(rset.description, [('Personne', 'Societe',)])
+ self.assertEqual(rset.description, [('Personne', 'Societe',)])
def test_insert_9(self):
self.execute("INSERT Societe X: X nom 'Lo'")
self.execute("INSERT Societe X: X nom 'Gi'")
self.execute("INSERT SubDivision X: X nom 'Lab'")
rset = self.execute("INSERT Personne X: X nom N, X travaille Y, X travaille_subdivision Z WHERE Y is Societe, Z is SubDivision, Y nom N")
- self.assertEquals(len(rset), 2)
- self.assertEquals(rset.description, [('Personne',), ('Personne',)])
- # self.assertSetEquals(set(x.nom for x in rset.entities()),
+ self.assertEqual(len(rset), 2)
+ self.assertEqual(rset.description, [('Personne',), ('Personne',)])
+ # self.assertSetEqual(set(x.nom for x in rset.entities()),
# ['Lo', 'Gi'])
- # self.assertSetEquals(set(y.nom for x in rset.entities() for y in x.travaille),
+ # self.assertSetEqual(set(y.nom for x in rset.entities() for y in x.travaille),
# ['Lo', 'Gi'])
- # self.assertEquals([y.nom for x in rset.entities() for y in x.travaille_subdivision],
+ # self.assertEqual([y.nom for x in rset.entities() for y in x.travaille_subdivision],
# ['Lab', 'Lab'])
def test_insert_query_error(self):
@@ -992,7 +992,7 @@
rset = self.execute('INSERT CWUser E, EmailAddress EM: E login "X", E upassword "X", '
'E primary_email EM, EM address "X", E in_group G '
'WHERE G name "managers"')
- self.assertEquals(list(rset.description[0]), ['CWUser', 'EmailAddress'])
+ self.assertEqual(list(rset.description[0]), ['CWUser', 'EmailAddress'])
# deletion queries tests ##################################################
@@ -1007,10 +1007,10 @@
def test_delete_2(self):
rset = self.execute("INSERT Personne X, Personne Y, Societe Z : X nom 'syt', Y nom 'adim', Z nom 'Logilab', X travaille Z, Y travaille Z")
- self.assertEquals(len(rset), 1)
- self.assertEquals(len(rset[0]), 3)
- self.assertEquals(rset.description[0], ('Personne', 'Personne', 'Societe'))
- self.assertEquals(self.execute('Any N WHERE X nom N, X eid %s'% rset[0][0])[0][0], 'syt')
+ self.assertEqual(len(rset), 1)
+ self.assertEqual(len(rset[0]), 3)
+ self.assertEqual(rset.description[0], ('Personne', 'Personne', 'Societe'))
+ self.assertEqual(self.execute('Any N WHERE X nom N, X eid %s'% rset[0][0])[0][0], 'syt')
rset = self.execute('Personne X WHERE X travaille Y, Y nom "Logilab"')
self.assertEqual(len(rset.rows), 2, rset.rows)
self.execute("DELETE X travaille Y WHERE X is Personne, Y nom 'Logilabo'")
@@ -1036,16 +1036,16 @@
teid2 = self.execute("INSERT Folder T: T name 'tutu'")[0][0]
self.execute('SET X see_also Y WHERE X eid %s, Y eid %s' % (teid1, teid2))
rset = self.execute('Any X,Y WHERE X see_also Y')
- self.assertEquals(len(rset) , 2, rset.rows)
+ self.assertEqual(len(rset) , 2, rset.rows)
self.execute('DELETE X see_also Y WHERE X eid %s, Y eid %s' % (teid1, teid2))
rset = self.execute('Any X,Y WHERE X see_also Y')
- self.assertEquals(len(rset) , 0)
+ self.assertEqual(len(rset) , 0)
self.execute('SET X see_also Y WHERE X eid %s, Y eid %s' % (teid1, teid2))
rset = self.execute('Any X,Y WHERE X see_also Y')
- self.assertEquals(len(rset) , 2)
+ self.assertEqual(len(rset) , 2)
self.execute('DELETE X see_also Y WHERE X eid %s, Y eid %s' % (teid2, teid1))
rset = self.execute('Any X,Y WHERE X see_also Y')
- self.assertEquals(len(rset) , 0)
+ self.assertEqual(len(rset) , 0)
def test_nonregr_delete_cache(self):
"""test that relations are properly cleaned when an entity is deleted
@@ -1060,9 +1060,9 @@
self.o.execute(s, "DELETE Email X")
sqlc = s.pool['system']
sqlc.execute('SELECT * FROM recipients_relation')
- self.assertEquals(len(sqlc.fetchall()), 0)
+ self.assertEqual(len(sqlc.fetchall()), 0)
sqlc.execute('SELECT * FROM owned_by_relation WHERE eid_from=%s'%eeid)
- self.assertEquals(len(sqlc.fetchall()), 0)
+ self.assertEqual(len(sqlc.fetchall()), 0)
def test_nonregr_delete_cache2(self):
eid = self.execute("INSERT Folder T: T name 'toto'")[0][0]
@@ -1075,13 +1075,13 @@
self.execute("DELETE Folder T WHERE T eid %s" % eid)
self.commit()
rset = self.execute("Any X WHERE X eid %(x)s", {'x': eid})
- self.assertEquals(rset.rows, [])
+ self.assertEqual(rset.rows, [])
rset = self.execute("Any X WHERE X eid %s" % eid)
- self.assertEquals(rset.rows, [])
+ self.assertEqual(rset.rows, [])
rset = self.execute("Folder X WHERE X eid %(x)s", {'x': eid})
- self.assertEquals(rset.rows, [])
+ self.assertEqual(rset.rows, [])
rset = self.execute("Folder X WHERE X eid %s" %eid)
- self.assertEquals(rset.rows, [])
+ self.assertEqual(rset.rows, [])
# update queries tests ####################################################
@@ -1097,7 +1097,7 @@
def test_update_2(self):
peid, seid = self.execute("INSERT Personne X, Societe Y: X nom 'bidule', Y nom 'toto'")[0]
rset = self.execute("SET X travaille Y WHERE X nom 'bidule', Y nom 'toto'")
- self.assertEquals(tuplify(rset.rows), [(peid, seid)])
+ self.assertEqual(tuplify(rset.rows), [(peid, seid)])
rset = self.execute('Any X, Y WHERE X travaille Y')
self.assertEqual(len(rset.rows), 1)
@@ -1125,8 +1125,8 @@
peid1 = self.execute("INSERT Personne Y: Y nom 'tutu'")[0][0]
peid2 = self.execute("INSERT Personne Y: Y nom 'toto'")[0][0]
self.execute("SET X nom 'tutu', Y nom 'toto' WHERE X nom 'toto', Y nom 'tutu'")
- self.assertEquals(self.execute('Any X WHERE X nom "toto"').rows, [[peid1]])
- self.assertEquals(self.execute('Any X WHERE X nom "tutu"').rows, [[peid2]])
+ self.assertEqual(self.execute('Any X WHERE X nom "toto"').rows, [[peid1]])
+ self.assertEqual(self.execute('Any X WHERE X nom "tutu"').rows, [[peid2]])
def test_update_multiple2(self):
ueid = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto'")[0][0]
@@ -1149,13 +1149,13 @@
{'order': orders[splitidx]})
orders2 = [r[0] for r in self.execute('Any O ORDERBY O WHERE ST name "Personne", X from_entity ST, X ordernum O')]
orders = orders[:splitidx] + [o+1 for o in orders[splitidx:]]
- self.assertEquals(orders2, orders)
+ self.assertEqual(orders2, orders)
def test_update_string_concat(self):
beid = self.execute("INSERT Bookmark Y: Y title 'toto', Y path '/view'")[0][0]
self.execute('SET X title XN + %(suffix)s WHERE X is Bookmark, X title XN', {'suffix': u'-moved'})
newname = self.execute('Any XN WHERE X eid %(x)s, X title XN', {'x': beid})[0][0]
- self.assertEquals(newname, 'toto-moved')
+ self.assertEqual(newname, 'toto-moved')
def test_update_query_error(self):
self.execute("INSERT Personne Y: Y nom 'toto'")
@@ -1168,34 +1168,34 @@
def test_insert_upassword(self):
rset = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto'")
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(rset.description, [('CWUser',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(rset.description, [('CWUser',)])
self.assertRaises(Unauthorized,
self.execute, "Any P WHERE X is CWUser, X login 'bob', X upassword P")
cursor = self.pool['system']
cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
% (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
passwd = str(cursor.fetchone()[0])
- self.assertEquals(passwd, crypt_password('toto', passwd[:2]))
+ self.assertEqual(passwd, crypt_password('toto', passwd[:2]))
rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword %(pwd)s",
{'pwd': Binary(passwd)})
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(rset.description, [('CWUser',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(rset.description, [('CWUser',)])
def test_update_upassword(self):
cursor = self.pool['system']
rset = self.execute("INSERT CWUser X: X login 'bob', X upassword %(pwd)s", {'pwd': 'toto'})
- self.assertEquals(rset.description[0][0], 'CWUser')
+ self.assertEqual(rset.description[0][0], 'CWUser')
rset = self.execute("SET X upassword %(pwd)s WHERE X is CWUser, X login 'bob'",
{'pwd': 'tutu'})
cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'"
% (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX))
passwd = str(cursor.fetchone()[0])
- self.assertEquals(passwd, crypt_password('tutu', passwd[:2]))
+ self.assertEqual(passwd, crypt_password('tutu', passwd[:2]))
rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword %(pwd)s",
{'pwd': Binary(passwd)})
- self.assertEquals(len(rset.rows), 1)
- self.assertEquals(rset.description, [('CWUser',)])
+ self.assertEqual(len(rset.rows), 1)
+ self.assertEqual(rset.description, [('CWUser',)])
# non regression tests ####################################################
@@ -1203,11 +1203,11 @@
teid = self.execute("INSERT Tag X: X name 'tag'")[0][0]
self.execute("SET X tags Y WHERE X name 'tag', Y is State, Y name 'activated'")
rset = self.execute('Any X WHERE T tags X')
- self.assertEquals(len(rset.rows), 1, rset.rows)
+ self.assertEqual(len(rset.rows), 1, rset.rows)
rset = self.execute('Any T WHERE T tags X, X is State')
- self.assertEquals(rset.rows, [[teid]])
+ self.assertEqual(rset.rows, [[teid]])
rset = self.execute('Any T WHERE T tags X')
- self.assertEquals(rset.rows, [[teid]])
+ self.assertEqual(rset.rows, [[teid]])
def test_nonregr_2(self):
teid = self.execute("INSERT Tag X: X name 'tag'")[0][0]
@@ -1216,7 +1216,7 @@
{'g': geid, 't': teid})
rset = self.execute('Any X WHERE E eid %(x)s, E tags X',
{'x': teid})
- self.assertEquals(rset.rows, [[geid]])
+ self.assertEqual(rset.rows, [[geid]])
def test_nonregr_3(self):
"""bad sql generated on the second query (destination_state is not
@@ -1224,7 +1224,7 @@
"""
rset = self.execute('Any S,ES,T WHERE S state_of WF, WF workflow_of ET, ET name "CWUser",'
'ES allowed_transition T, T destination_state S')
- self.assertEquals(len(rset.rows), 2)
+ self.assertEqual(len(rset.rows), 2)
def test_nonregr_4(self):
# fix variables'type, else we get (nb of entity types with a 'name' attribute)**3
@@ -1232,7 +1232,7 @@
# by the server (or client lib)
rset = self.execute('Any ER,SE,OE WHERE SE name "Comment", ER name "comments", OE name "Comment",'
'ER is CWRType, SE is CWEType, OE is CWEType')
- self.assertEquals(len(rset), 1)
+ self.assertEqual(len(rset), 1)
def test_nonregr_5(self):
# jpl #15505: equivalent queries returning different result sets
@@ -1252,9 +1252,9 @@
rset4 = self.execute('Any N,U WHERE N todo_by U, T eid %s,'
'N filed_under T, W concerne N,'
'W filed_under A, A eid %s' % (teid1, teid2))
- self.assertEquals(rset1.rows, rset2.rows)
- self.assertEquals(rset1.rows, rset3.rows)
- self.assertEquals(rset1.rows, rset4.rows)
+ self.assertEqual(rset1.rows, rset2.rows)
+ self.assertEqual(rset1.rows, rset3.rows)
+ self.assertEqual(rset1.rows, rset4.rows)
def test_nonregr_6(self):
self.execute('Any N,COUNT(S) GROUPBY N ORDERBY COUNT(N) WHERE S name N, S is State')
@@ -1272,7 +1272,7 @@
rset = self.execute('Any lower(N) ORDERBY LOWER(N) WHERE X is Tag, X name N,'
'X owned_by U, U eid %(x)s',
{'x':self.session.user.eid})
- self.assertEquals(rset.rows, [[u'\xe9name0']])
+ self.assertEqual(rset.rows, [[u'\xe9name0']])
def test_nonregr_description(self):
@@ -1286,8 +1286,8 @@
self.execute("SET X in_basket B WHERE X is Personne")
self.execute("SET X in_basket B WHERE X is Societe")
rset = self.execute('Any X WHERE X in_basket B, B eid %s' % beid)
- self.assertEquals(len(rset), 2)
- self.assertEquals(rset.description, [('Personne',), ('Societe',)])
+ self.assertEqual(len(rset), 2)
+ self.assertEqual(rset.description, [('Personne',), ('Societe',)])
def test_nonregr_cache_1(self):
@@ -1297,19 +1297,19 @@
{'y': beid})
rset = self.execute("Any X WHERE X in_basket B, B eid %(x)s",
{'x': beid})
- self.assertEquals(rset.rows, [[peid]])
+ self.assertEqual(rset.rows, [[peid]])
rset = self.execute("Any X WHERE X in_basket B, B eid %(x)s",
{'x': beid})
- self.assertEquals(rset.rows, [[peid]])
+ self.assertEqual(rset.rows, [[peid]])
def test_nonregr_has_text_cache(self):
eid1 = self.execute("INSERT Personne X: X nom 'bidule'")[0][0]
eid2 = self.execute("INSERT Personne X: X nom 'tag'")[0][0]
self.commit()
rset = self.execute("Any X WHERE X has_text %(text)s", {'text': 'bidule'})
- self.assertEquals(rset.rows, [[eid1]])
+ self.assertEqual(rset.rows, [[eid1]])
rset = self.execute("Any X WHERE X has_text %(text)s", {'text': 'tag'})
- self.assertEquals(rset.rows, [[eid2]])
+ self.assertEqual(rset.rows, [[eid2]])
def test_nonregr_sortterm_management(self):
"""Error: Variable has no attribute 'sql' in rql2sql.py (visit_variable)
@@ -1334,16 +1334,16 @@
self.execute("SET X todo_by Y WHERE X is Note, Y eid %s" % ueid)
rset = self.execute('Any N WHERE N todo_by U, N is Note, U eid %s, N filed_under T, T eid %s'
% (ueid, teid1))
- self.assertEquals(len(rset), 1)
+ self.assertEqual(len(rset), 1)
def test_nonregr_XXX(self):
teid = self.execute('Transition S WHERE S name "deactivate"')[0][0]
rset = self.execute('Any O WHERE O is State, '
'S eid %(x)s, S transition_of ET, O state_of ET', {'x': teid})
- self.assertEquals(len(rset), 2)
+ self.assertEqual(len(rset), 2)
rset = self.execute('Any O WHERE O is State, NOT S destination_state O, '
'S eid %(x)s, S transition_of ET, O state_of ET', {'x': teid})
- self.assertEquals(len(rset), 1)
+ self.assertEqual(len(rset), 1)
def test_nonregr_set_datetime(self):
@@ -1360,9 +1360,9 @@
ueid = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto', X in_group G "
"WHERE G name 'users'")[0][0]
rset = self.execute("CWUser U")
- self.assertEquals(len(rset), 3) # bob + admin + anon
+ self.assertEqual(len(rset), 3) # bob + admin + anon
rset = self.execute("Any U WHERE NOT U owned_by U")
- self.assertEquals(len(rset), 0) # even admin created at repo initialization time should belong to itself
+ self.assertEqual(len(rset), 0) # even admin created at repo initialization time should belong to itself
def test_nonreg_update_index(self):
# this is the kind of queries generated by "cubicweb-ctl db-check -ry"
@@ -1377,11 +1377,11 @@
self.execute('Any X,S, MAX(T) GROUPBY X,S ORDERBY S WHERE X is CWUser, T tags X, S eid IN(%s), X in_state S' % seid)
def test_nonregr_solution_cache(self):
- self.skip('XXX should be fixed or documented') # (doesn't occur if cache key is provided.)
+ self.skipTest('XXX should be fixed or documented') # (doesn't occur if cache key is provided.)
rset = self.execute('Any X WHERE X is CWUser, X eid %(x)s', {'x':self.ueid})
- self.assertEquals(len(rset), 1)
+ self.assertEqual(len(rset), 1)
rset = self.execute('Any X WHERE X is CWUser, X eid %(x)s', {'x':12345})
- self.assertEquals(len(rset), 0)
+ self.assertEqual(len(rset), 0)
def test_nonregr_final_norestr(self):
self.assertRaises(BadRQLQuery, self.execute, 'Date X')