[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family
--- a/devtools/test/unittest_dbfill.py Wed Sep 14 09:10:58 2011 +0200
+++ b/devtools/test/unittest_dbfill.py Wed Sep 14 09:11:50 2011 +0200
@@ -72,7 +72,7 @@
"""test value generation from a given domain value"""
firstname = self.person_valgen.generate_attribute_value({}, 'firstname', 12)
possible_choices = self._choice_func('Person', 'firstname')
- self.failUnless(firstname in possible_choices,
+ self.assertTrue(firstname in possible_choices,
'%s not in %s' % (firstname, possible_choices))
def test_choice(self):
@@ -80,21 +80,21 @@
# Test for random index
for index in range(5):
sx_value = self.person_valgen.generate_attribute_value({}, 'civility', index)
- self.failUnless(sx_value in ('Mr', 'Mrs', 'Ms'))
+ self.assertTrue(sx_value in ('Mr', 'Mrs', 'Ms'))
def test_integer(self):
"""test integer generation"""
# Test for random index
for index in range(5):
cost_value = self.bug_valgen.generate_attribute_value({}, 'cost', index)
- self.failUnless(cost_value in range(index+1))
+ self.assertTrue(cost_value in range(index+1))
def test_date(self):
"""test date generation"""
# Test for random index
for index in range(10):
date_value = self.person_valgen.generate_attribute_value({}, 'birthday', index)
- self.failUnless(isinstance(date_value, datetime.date))
+ self.assertTrue(isinstance(date_value, datetime.date))
def test_phone(self):
"""tests make_tel utility"""
--- a/devtools/test/unittest_fill.py Wed Sep 14 09:10:58 2011 +0200
+++ b/devtools/test/unittest_fill.py Wed Sep 14 09:11:50 2011 +0200
@@ -41,31 +41,31 @@
def test_autoextend(self):
- self.failIf('generate_server' in dir(ValueGenerator))
+ self.assertFalse('generate_server' in dir(ValueGenerator))
class MyValueGenerator(ValueGenerator):
def generate_server(self, index):
return attrname
- self.failUnless('generate_server' in dir(ValueGenerator))
+ self.assertTrue('generate_server' in dir(ValueGenerator))
def test_bad_signature_detection(self):
- self.failIf('generate_server' in dir(ValueGenerator))
+ self.assertFalse('generate_server' in dir(ValueGenerator))
try:
class MyValueGenerator(ValueGenerator):
def generate_server(self):
pass
except TypeError:
- self.failIf('generate_server' in dir(ValueGenerator))
+ self.assertFalse('generate_server' in dir(ValueGenerator))
else:
self.fail('TypeError not raised')
def test_signature_extension(self):
- self.failIf('generate_server' in dir(ValueGenerator))
+ self.assertFalse('generate_server' in dir(ValueGenerator))
class MyValueGenerator(ValueGenerator):
def generate_server(self, index, foo):
pass
- self.failUnless('generate_server' in dir(ValueGenerator))
+ self.assertTrue('generate_server' in dir(ValueGenerator))
if __name__ == '__main__':
--- a/entities/test/unittest_base.py Wed Sep 14 09:10:58 2011 +0200
+++ b/entities/test/unittest_base.py Wed Sep 14 09:11:50 2011 +0200
@@ -88,10 +88,10 @@
def test_matching_groups(self):
e = self.execute('CWUser X WHERE X login "admin"').get_entity(0, 0)
- self.failUnless(e.matching_groups('managers'))
- self.failIf(e.matching_groups('xyz'))
- self.failUnless(e.matching_groups(('xyz', 'managers')))
- self.failIf(e.matching_groups(('xyz', 'abcd')))
+ self.assertTrue(e.matching_groups('managers'))
+ self.assertFalse(e.matching_groups('xyz'))
+ self.assertTrue(e.matching_groups(('xyz', 'managers')))
+ self.assertFalse(e.matching_groups(('xyz', 'abcd')))
def test_dc_title_and_name(self):
e = self.execute('CWUser U WHERE U login "member"').get_entity(0, 0)
@@ -131,12 +131,12 @@
self.vreg['etypes'].initialization_completed()
MyUser_ = self.vreg['etypes'].etype_class('CWUser')
# a copy is done systematically
- self.failUnless(issubclass(MyUser_, MyUser))
- self.failUnless(implements(MyUser_, IMileStone))
- self.failUnless(implements(MyUser_, ICalendarable))
+ self.assertTrue(issubclass(MyUser_, MyUser))
+ self.assertTrue(implements(MyUser_, IMileStone))
+ self.assertTrue(implements(MyUser_, ICalendarable))
# original class should not have beed modified, only the copy
- self.failUnless(implements(MyUser, IMileStone))
- self.failIf(implements(MyUser, ICalendarable))
+ self.assertTrue(implements(MyUser, IMileStone))
+ self.assertFalse(implements(MyUser, ICalendarable))
class SpecializedEntityClassesTC(CubicWebTC):
@@ -149,7 +149,7 @@
def test_etype_class_selection_and_specialization(self):
# no specific class for Subdivisions, the default one should be selected
eclass = self.select_eclass('SubDivision')
- self.failUnless(eclass.__autogenerated__)
+ self.assertTrue(eclass.__autogenerated__)
#self.assertEqual(eclass.__bases__, (AnyEntity,))
# build class from most generic to most specific and make
# sure the most specific is always selected
@@ -159,8 +159,8 @@
__regid__ = etype
self.vreg.register(Foo)
eclass = self.select_eclass('SubDivision')
- self.failUnless(eclass.__autogenerated__)
- self.failIf(eclass is Foo)
+ self.assertTrue(eclass.__autogenerated__)
+ self.assertFalse(eclass is Foo)
if etype == 'SubDivision':
self.assertEqual(eclass.__bases__, (Foo,))
else:
--- a/entities/test/unittest_wfobjs.py Wed Sep 14 09:10:58 2011 +0200
+++ b/entities/test/unittest_wfobjs.py Wed Sep 14 09:11:50 2011 +0200
@@ -567,7 +567,7 @@
# test initial state is set
rset = self.execute('Any N WHERE S name N, X in_state S, X eid %(x)s',
{'x' : ueid})
- self.failIf(rset, rset.rows)
+ self.assertFalse(rset, rset.rows)
self.commit()
initialstate = self.execute('Any N WHERE S name N, X in_state S, X eid %(x)s',
{'x' : ueid})[0][0]
--- a/etwist/test/unittest_server.py Wed Sep 14 09:10:58 2011 +0200
+++ b/etwist/test/unittest_server.py Wed Sep 14 09:11:50 2011 +0200
@@ -69,7 +69,7 @@
def test_cache(self):
concat = ConcatFiles(self.config, ('cubicweb.ajax.js', 'jquery.js'))
- self.failUnless(osp.isfile(concat.path))
+ self.assertTrue(osp.isfile(concat.path))
def test_404(self):
# when not in debug mode, should not crash
--- a/hooks/test/unittest_bookmarks.py Wed Sep 14 09:10:58 2011 +0200
+++ b/hooks/test/unittest_bookmarks.py Wed Sep 14 09:11:50 2011 +0200
@@ -28,10 +28,10 @@
self.commit()
self.execute('DELETE X bookmarked_by U WHERE U login "admin"')
self.commit()
- self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': beid}))
+ self.assertTrue(self.execute('Any X WHERE X eid %(x)s', {'x': beid}))
self.execute('DELETE X bookmarked_by U WHERE U login "anon"')
self.commit()
- self.failIf(self.execute('Any X WHERE X eid %(x)s', {'x': beid}))
+ self.assertFalse(self.execute('Any X WHERE X eid %(x)s', {'x': beid}))
if __name__ == '__main__':
unittest_main()
--- a/hooks/test/unittest_hooks.py Wed Sep 14 09:10:58 2011 +0200
+++ b/hooks/test/unittest_hooks.py Wed Sep 14 09:11:50 2011 +0200
@@ -117,7 +117,7 @@
self.repo.connect, u'toto', password='hop')
self.commit()
cnxid = self.repo.connect(u'toto', password='hop')
- self.failIfEqual(cnxid, self.session.id)
+ self.assertNotEqual(cnxid, self.session.id)
self.execute('DELETE CWUser X WHERE X login "toto"')
self.repo.execute(cnxid, 'State X')
self.commit()
@@ -151,7 +151,7 @@
eid = self.execute('INSERT EmailAddress X: X address "toto@logilab.fr"')[0][0]
self.execute('DELETE EmailAddress X WHERE X eid %s' % eid)
self.commit()
- self.failIf(self.execute('Any X WHERE X created_by Y, X eid >= %(x)s', {'x': eid}))
+ self.assertFalse(self.execute('Any X WHERE X created_by Y, X eid >= %(x)s', {'x': eid}))
--- a/hooks/test/unittest_integrity.py Wed Sep 14 09:10:58 2011 +0200
+++ b/hooks/test/unittest_integrity.py Wed Sep 14 09:11:50 2011 +0200
@@ -62,7 +62,7 @@
self.execute('INSERT EmailPart X: X content_format "text/plain", X ordernum 1, X content "this is a test"')
self.execute('INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y, X parts P '
'WHERE Y is EmailAddress, P is EmailPart')
- self.failUnless(self.execute('Email X WHERE X sender Y'))
+ self.assertTrue(self.execute('Email X WHERE X sender Y'))
self.commit()
self.execute('DELETE Email X')
rset = self.execute('Any X WHERE X is EmailPart')
--- a/hooks/test/unittest_syncschema.py Wed Sep 14 09:10:58 2011 +0200
+++ b/hooks/test/unittest_syncschema.py Wed Sep 14 09:11:50 2011 +0200
@@ -60,18 +60,18 @@
self.session.set_cnxset()
dbhelper = self.session.cnxset.source('system').dbhelper
sqlcursor = self.session.cnxset['system']
- self.failIf(schema.has_entity('Societe2'))
- self.failIf(schema.has_entity('concerne2'))
+ self.assertFalse(schema.has_entity('Societe2'))
+ self.assertFalse(schema.has_entity('concerne2'))
# schema should be update on insertion (after commit)
eeid = self.execute('INSERT CWEType X: X name "Societe2", X description "", X final FALSE')[0][0]
self._set_perms(eeid)
self.execute('INSERT CWRType X: X name "concerne2", X description "", X final FALSE, X symmetric FALSE')
- self.failIf(schema.has_entity('Societe2'))
- self.failIf(schema.has_entity('concerne2'))
+ self.assertFalse(schema.has_entity('Societe2'))
+ self.assertFalse(schema.has_entity('concerne2'))
# have to commit before adding definition relations
self.commit()
- self.failUnless(schema.has_entity('Societe2'))
- self.failUnless(schema.has_relation('concerne2'))
+ self.assertTrue(schema.has_entity('Societe2'))
+ self.assertTrue(schema.has_relation('concerne2'))
attreid = self.execute('INSERT CWAttribute X: X cardinality "11", X defaultval "noname", '
' X indexed TRUE, X relation_type RT, X from_entity E, X to_entity F '
'WHERE RT name "name", E name "Societe2", F name "String"')[0][0]
@@ -80,13 +80,13 @@
'INSERT CWRelation X: X cardinality "**", X relation_type RT, X from_entity E, X to_entity E '
'WHERE RT name "concerne2", E name "Societe2"')[0][0]
self._set_perms(concerne2_rdef_eid)
- self.failIf('name' in schema['Societe2'].subject_relations())
- self.failIf('concerne2' in schema['Societe2'].subject_relations())
- self.failIf(self.index_exists('Societe2', 'name'))
+ self.assertFalse('name' in schema['Societe2'].subject_relations())
+ self.assertFalse('concerne2' in schema['Societe2'].subject_relations())
+ self.assertFalse(self.index_exists('Societe2', 'name'))
self.commit()
- self.failUnless('name' in schema['Societe2'].subject_relations())
- self.failUnless('concerne2' in schema['Societe2'].subject_relations())
- self.failUnless(self.index_exists('Societe2', 'name'))
+ self.assertTrue('name' in schema['Societe2'].subject_relations())
+ self.assertTrue('concerne2' in schema['Societe2'].subject_relations())
+ self.assertTrue(self.index_exists('Societe2', 'name'))
# now we should be able to insert and query Societe2
s2eid = self.execute('INSERT Societe2 X: X name "logilab"')[0][0]
self.execute('Societe2 X WHERE X name "logilab"')
@@ -101,20 +101,20 @@
self.commit()
self.execute('DELETE CWRelation X WHERE X eid %(x)s', {'x': concerne2_rdef_eid})
self.commit()
- self.failUnless('concerne2' in schema['CWUser'].subject_relations())
- self.failIf('concerne2' in schema['Societe2'].subject_relations())
- self.failIf(self.execute('Any X WHERE X concerne2 Y'))
+ self.assertTrue('concerne2' in schema['CWUser'].subject_relations())
+ self.assertFalse('concerne2' in schema['Societe2'].subject_relations())
+ self.assertFalse(self.execute('Any X WHERE X concerne2 Y'))
# schema should be cleaned on delete (after commit)
self.execute('DELETE CWEType X WHERE X name "Societe2"')
self.execute('DELETE CWRType X WHERE X name "concerne2"')
- self.failUnless(self.index_exists('Societe2', 'name'))
- self.failUnless(schema.has_entity('Societe2'))
- self.failUnless(schema.has_relation('concerne2'))
+ self.assertTrue(self.index_exists('Societe2', 'name'))
+ self.assertTrue(schema.has_entity('Societe2'))
+ self.assertTrue(schema.has_relation('concerne2'))
self.commit()
- self.failIf(self.index_exists('Societe2', 'name'))
- self.failIf(schema.has_entity('Societe2'))
- self.failIf(schema.has_entity('concerne2'))
- self.failIf('concerne2' in schema['CWUser'].subject_relations())
+ self.assertFalse(self.index_exists('Societe2', 'name'))
+ self.assertFalse(schema.has_entity('Societe2'))
+ self.assertFalse(schema.has_entity('concerne2'))
+ self.assertFalse('concerne2' in schema['CWUser'].subject_relations())
def test_is_instance_of_insertions(self):
seid = self.execute('INSERT Transition T: T name "subdiv"')[0][0]
@@ -123,15 +123,15 @@
instanceof_etypes = [etype for etype, in self.execute('Any ETN WHERE X eid %s, X is_instance_of ET, ET name ETN' % seid)]
self.assertEqual(sorted(instanceof_etypes), ['BaseTransition', 'Transition'])
snames = [name for name, in self.execute('Any N WHERE S is BaseTransition, S name N')]
- self.failIf('subdiv' in snames)
+ self.assertFalse('subdiv' in snames)
snames = [name for name, in self.execute('Any N WHERE S is_instance_of BaseTransition, S name N')]
- self.failUnless('subdiv' in snames)
+ self.assertTrue('subdiv' in snames)
def test_perms_synchronization_1(self):
schema = self.repo.schema
self.assertEqual(schema['CWUser'].get_groups('read'), set(('managers', 'users')))
- self.failUnless(self.execute('Any X, Y WHERE X is CWEType, X name "CWUser", Y is CWGroup, Y name "users"')[0])
+ self.assertTrue(self.execute('Any X, Y WHERE X is CWEType, X name "CWUser", Y is CWGroup, Y name "users"')[0])
self.execute('DELETE X read_permission Y WHERE X is CWEType, X name "CWUser", Y name "users"')
self.assertEqual(schema['CWUser'].get_groups('read'), set(('managers', 'users', )))
self.commit()
@@ -173,13 +173,13 @@
self.session.set_cnxset()
dbhelper = self.session.cnxset.source('system').dbhelper
sqlcursor = self.session.cnxset['system']
- self.failUnless(self.schema['state_of'].inlined)
+ self.assertTrue(self.schema['state_of'].inlined)
try:
self.execute('SET X inlined FALSE WHERE X name "state_of"')
- self.failUnless(self.schema['state_of'].inlined)
+ self.assertTrue(self.schema['state_of'].inlined)
self.commit()
- self.failIf(self.schema['state_of'].inlined)
- self.failIf(self.index_exists('State', 'state_of'))
+ self.assertFalse(self.schema['state_of'].inlined)
+ self.assertFalse(self.index_exists('State', 'state_of'))
rset = self.execute('Any X, Y WHERE X state_of Y')
self.assertEqual(len(rset), 2) # user states
except:
@@ -187,10 +187,10 @@
traceback.print_exc()
finally:
self.execute('SET X inlined TRUE WHERE X name "state_of"')
- self.failIf(self.schema['state_of'].inlined)
+ self.assertFalse(self.schema['state_of'].inlined)
self.commit()
- self.failUnless(self.schema['state_of'].inlined)
- self.failUnless(self.index_exists('State', 'state_of'))
+ self.assertTrue(self.schema['state_of'].inlined)
+ self.assertTrue(self.index_exists('State', 'state_of'))
rset = self.execute('Any X, Y WHERE X state_of Y')
self.assertEqual(len(rset), 2)
@@ -200,18 +200,18 @@
sqlcursor = self.session.cnxset['system']
try:
self.execute('SET X indexed FALSE WHERE X relation_type R, R name "name"')
- self.failUnless(self.schema['name'].rdef('Workflow', 'String').indexed)
- self.failUnless(self.index_exists('Workflow', 'name'))
+ self.assertTrue(self.schema['name'].rdef('Workflow', 'String').indexed)
+ self.assertTrue(self.index_exists('Workflow', 'name'))
self.commit()
- self.failIf(self.schema['name'].rdef('Workflow', 'String').indexed)
- self.failIf(self.index_exists('Workflow', 'name'))
+ self.assertFalse(self.schema['name'].rdef('Workflow', 'String').indexed)
+ self.assertFalse(self.index_exists('Workflow', 'name'))
finally:
self.execute('SET X indexed TRUE WHERE X relation_type R, R name "name"')
- self.failIf(self.schema['name'].rdef('Workflow', 'String').indexed)
- self.failIf(self.index_exists('Workflow', 'name'))
+ self.assertFalse(self.schema['name'].rdef('Workflow', 'String').indexed)
+ self.assertFalse(self.index_exists('Workflow', 'name'))
self.commit()
- self.failUnless(self.schema['name'].rdef('Workflow', 'String').indexed)
- self.failUnless(self.index_exists('Workflow', 'name'))
+ self.assertTrue(self.schema['name'].rdef('Workflow', 'String').indexed)
+ self.assertTrue(self.index_exists('Workflow', 'name'))
def test_unique_change(self):
self.session.set_cnxset()
@@ -221,20 +221,20 @@
self.execute('INSERT CWConstraint X: X cstrtype CT, DEF constrained_by X '
'WHERE CT name "UniqueConstraint", DEF relation_type RT, DEF from_entity E,'
'RT name "name", E name "Workflow"')
- self.failIf(self.schema['Workflow'].has_unique_values('name'))
- self.failIf(self.index_exists('Workflow', 'name', unique=True))
+ self.assertFalse(self.schema['Workflow'].has_unique_values('name'))
+ self.assertFalse(self.index_exists('Workflow', 'name', unique=True))
self.commit()
- self.failUnless(self.schema['Workflow'].has_unique_values('name'))
- self.failUnless(self.index_exists('Workflow', 'name', unique=True))
+ self.assertTrue(self.schema['Workflow'].has_unique_values('name'))
+ self.assertTrue(self.index_exists('Workflow', 'name', unique=True))
finally:
self.execute('DELETE DEF constrained_by X WHERE X cstrtype CT, '
'CT name "UniqueConstraint", DEF relation_type RT, DEF from_entity E,'
'RT name "name", E name "Workflow"')
- self.failUnless(self.schema['Workflow'].has_unique_values('name'))
- self.failUnless(self.index_exists('Workflow', 'name', unique=True))
+ self.assertTrue(self.schema['Workflow'].has_unique_values('name'))
+ self.assertTrue(self.index_exists('Workflow', 'name', unique=True))
self.commit()
- self.failIf(self.schema['Workflow'].has_unique_values('name'))
- self.failIf(self.index_exists('Workflow', 'name', unique=True))
+ self.assertFalse(self.schema['Workflow'].has_unique_values('name'))
+ self.assertFalse(self.index_exists('Workflow', 'name', unique=True))
def test_required_change_1(self):
self.execute('SET DEF cardinality "?1" '
@@ -267,8 +267,8 @@
{'x': attreid})
self.commit()
self.schema.rebuild_infered_relations()
- self.failUnless('Transition' in self.schema['messageid'].subjects())
- self.failUnless('WorkflowTransition' in self.schema['messageid'].subjects())
+ self.assertTrue('Transition' in self.schema['messageid'].subjects())
+ self.assertTrue('WorkflowTransition' in self.schema['messageid'].subjects())
self.execute('Any X WHERE X is_instance_of BaseTransition, X messageid "hop"')
def test_change_fulltextindexed(self):
@@ -283,7 +283,7 @@
'A from_entity E, A relation_type R, R name "subject"')
self.commit()
rset = req.execute('Any X WHERE X has_text "rick.roll"')
- self.failIf(rset)
+ self.assertFalse(rset)
assert req.execute('SET A fulltextindexed TRUE '
'WHERE A from_entity E, A relation_type R, '
'E name "Email", R name "subject"')
--- a/server/test/unittest_checkintegrity.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_checkintegrity.py Wed Sep 14 09:11:50 2011 +0200
@@ -46,9 +46,9 @@
def test_reindex_all(self):
self.execute('INSERT Personne X: X nom "toto", X prenom "tutu"')
self.session.commit(False)
- self.failUnless(self.execute('Any X WHERE X has_text "tutu"'))
+ self.assertTrue(self.execute('Any X WHERE X has_text "tutu"'))
reindex_entities(self.repo.schema, self.session, withpb=False)
- self.failUnless(self.execute('Any X WHERE X has_text "tutu"'))
+ self.assertTrue(self.execute('Any X WHERE X has_text "tutu"'))
def test_reindex_etype(self):
self.execute('INSERT Personne X: X nom "toto", X prenom "tutu"')
@@ -56,8 +56,8 @@
self.session.commit(False)
reindex_entities(self.repo.schema, self.session, withpb=False,
etypes=('Personne',))
- self.failUnless(self.execute('Any X WHERE X has_text "tutu"'))
- self.failUnless(self.execute('Any X WHERE X has_text "toto"'))
+ self.assertTrue(self.execute('Any X WHERE X has_text "tutu"'))
+ self.assertTrue(self.execute('Any X WHERE X has_text "toto"'))
if __name__ == '__main__':
unittest_main()
--- a/server/test/unittest_datafeed.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_datafeed.py Wed Sep 14 09:11:50 2011 +0200
@@ -115,8 +115,8 @@
req = self.request()
req.execute('DELETE CWSource S WHERE S name "myrenamedfeed"')
self.commit()
- self.failIf(self.execute('Card X WHERE X title "cubicweb.org"'))
- self.failIf(self.execute('Any X WHERE X has_text "cubicweb.org"'))
+ self.assertFalse(self.execute('Card X WHERE X title "cubicweb.org"'))
+ self.assertFalse(self.execute('Any X WHERE X has_text "cubicweb.org"'))
if __name__ == '__main__':
from logilab.common.testlib import unittest_main
--- a/server/test/unittest_ldapuser.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_ldapuser.py Wed Sep 14 09:11:50 2011 +0200
@@ -262,7 +262,7 @@
def test_multiple_entities_from_different_sources(self):
req = self.request()
self.create_user(req, 'cochon')
- self.failUnless(self.sexecute('Any X,Y WHERE X login %(syt)s, Y login "cochon"', {'syt': SYT}))
+ self.assertTrue(self.sexecute('Any X,Y WHERE X login %(syt)s, Y login "cochon"', {'syt': SYT}))
def test_exists1(self):
self.session.set_cnxset()
@@ -288,9 +288,9 @@
self.create_user(req, 'comme')
self.create_user(req, 'cochon')
self.sexecute('SET X copain Y WHERE X login "comme", Y login "cochon"')
- self.failUnless(self.sexecute('Any X, Y WHERE X copain Y, X login "comme", Y login "cochon"'))
+ self.assertTrue(self.sexecute('Any X, Y WHERE X copain Y, X login "comme", Y login "cochon"'))
self.sexecute('SET X copain Y WHERE X login %(syt)s, Y login "cochon"', {'syt': SYT})
- self.failUnless(self.sexecute('Any X, Y WHERE X copain Y, X login %(syt)s, Y login "cochon"', {'syt': SYT}))
+ self.assertTrue(self.sexecute('Any X, Y WHERE X copain Y, X login %(syt)s, Y login "cochon"', {'syt': SYT}))
rset = self.sexecute('Any GN,L WHERE X in_group G, X login L, G name GN, G name "managers" '
'OR EXISTS(X copain T, T login in ("comme", "cochon"))')
self.assertEqual(sorted(rset.rows), [['managers', 'admin'], ['users', 'comme'], ['users', SYT]])
@@ -392,8 +392,8 @@
'type': 'CWUser',
'extid': None})
self.assertEqual(e.cw_source[0].name, 'system')
- self.failUnless(e.creation_date)
- self.failUnless(e.modification_date)
+ self.assertTrue(e.creation_date)
+ self.assertTrue(e.modification_date)
# XXX test some password has been set
source.synchronize()
rset = self.sexecute('CWUser X WHERE X login %(login)s', {'login': SYT})
--- a/server/test/unittest_migractions.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_migractions.py Wed Sep 14 09:11:50 2011 +0200
@@ -74,13 +74,13 @@
self.repo.vreg['etypes'].clear_caches()
def test_add_attribute_int(self):
- self.failIf('whatever' in self.schema)
+ self.assertFalse('whatever' in self.schema)
self.request().create_entity('Note')
self.commit()
orderdict = dict(self.mh.rqlexec('Any RTN, O WHERE X name "Note", RDEF from_entity X, '
'RDEF relation_type RT, RDEF ordernum O, RT name RTN'))
self.mh.cmd_add_attribute('Note', 'whatever')
- self.failUnless('whatever' in self.schema)
+ self.assertTrue('whatever' in self.schema)
self.assertEqual(self.schema['whatever'].subjects(), ('Note',))
self.assertEqual(self.schema['whatever'].objects(), ('Int',))
self.assertEqual(self.schema['Note'].default('whatever'), 2)
@@ -108,12 +108,12 @@
self.mh.rollback()
def test_add_attribute_varchar(self):
- self.failIf('whatever' in self.schema)
+ self.assertFalse('whatever' in self.schema)
self.request().create_entity('Note')
self.commit()
- self.failIf('shortpara' in self.schema)
+ self.assertFalse('shortpara' in self.schema)
self.mh.cmd_add_attribute('Note', 'shortpara')
- self.failUnless('shortpara' in self.schema)
+ self.assertTrue('shortpara' in self.schema)
self.assertEqual(self.schema['shortpara'].subjects(), ('Note', ))
self.assertEqual(self.schema['shortpara'].objects(), ('String', ))
# test created column is actually a varchar(64)
@@ -128,10 +128,10 @@
self.mh.rollback()
def test_add_datetime_with_default_value_attribute(self):
- self.failIf('mydate' in self.schema)
- self.failIf('shortpara' in self.schema)
+ self.assertFalse('mydate' in self.schema)
+ self.assertFalse('shortpara' in self.schema)
self.mh.cmd_add_attribute('Note', 'mydate')
- self.failUnless('mydate' in self.schema)
+ self.assertTrue('mydate' in self.schema)
self.assertEqual(self.schema['mydate'].subjects(), ('Note', ))
self.assertEqual(self.schema['mydate'].objects(), ('Date', ))
testdate = date(2005, 12, 13)
@@ -167,17 +167,17 @@
self.mh.rollback()
def test_rename_attribute(self):
- self.failIf('civility' in self.schema)
+ self.assertFalse('civility' in self.schema)
eid1 = self.mh.rqlexec('INSERT Personne X: X nom "lui", X sexe "M"')[0][0]
eid2 = self.mh.rqlexec('INSERT Personne X: X nom "l\'autre", X sexe NULL')[0][0]
self.mh.cmd_rename_attribute('Personne', 'sexe', 'civility')
- self.failIf('sexe' in self.schema)
- self.failUnless('civility' in self.schema)
+ self.assertFalse('sexe' in self.schema)
+ self.assertTrue('civility' in self.schema)
# test data has been backported
c1 = self.mh.rqlexec('Any C WHERE X eid %s, X civility C' % eid1)[0][0]
- self.failUnlessEqual(c1, 'M')
+ self.assertEqual(c1, 'M')
c2 = self.mh.rqlexec('Any C WHERE X eid %s, X civility C' % eid2)[0][0]
- self.failUnlessEqual(c2, None)
+ self.assertEqual(c2, None)
def test_workflow_actions(self):
@@ -192,13 +192,13 @@
self.assertEqual(s1, "foo")
def test_add_entity_type(self):
- self.failIf('Folder2' in self.schema)
- self.failIf('filed_under2' in self.schema)
+ self.assertFalse('Folder2' in self.schema)
+ self.assertFalse('filed_under2' in self.schema)
self.mh.cmd_add_entity_type('Folder2')
- self.failUnless('Folder2' in self.schema)
- self.failUnless(self.execute('CWEType X WHERE X name "Folder2"'))
- self.failUnless('filed_under2' in self.schema)
- self.failUnless(self.execute('CWRType X WHERE X name "filed_under2"'))
+ self.assertTrue('Folder2' in self.schema)
+ self.assertTrue(self.execute('CWEType X WHERE X name "Folder2"'))
+ self.assertTrue('filed_under2' in self.schema)
+ self.assertTrue(self.execute('CWRType X WHERE X name "filed_under2"'))
self.schema.rebuild_infered_relations()
self.assertEqual(sorted(str(rs) for rs in self.schema['Folder2'].subject_relations()),
['created_by', 'creation_date', 'cw_source', 'cwuri',
@@ -214,7 +214,7 @@
self.assertEqual(self.schema['filed_under2'].objects(), ('Folder2',))
eschema = self.schema.eschema('Folder2')
for cstr in eschema.rdef('name').constraints:
- self.failUnless(hasattr(cstr, 'eid'))
+ self.assertTrue(hasattr(cstr, 'eid'))
def test_add_drop_entity_type(self):
self.mh.cmd_add_entity_type('Folder2')
@@ -227,23 +227,23 @@
self.commit()
eschema = self.schema.eschema('Folder2')
self.mh.cmd_drop_entity_type('Folder2')
- self.failIf('Folder2' in self.schema)
- self.failIf(self.execute('CWEType X WHERE X name "Folder2"'))
+ self.assertFalse('Folder2' in self.schema)
+ self.assertFalse(self.execute('CWEType X WHERE X name "Folder2"'))
# test automatic workflow deletion
- self.failIf(self.execute('Workflow X WHERE NOT X workflow_of ET'))
- self.failIf(self.execute('State X WHERE NOT X state_of WF'))
- self.failIf(self.execute('Transition X WHERE NOT X transition_of WF'))
+ self.assertFalse(self.execute('Workflow X WHERE NOT X workflow_of ET'))
+ self.assertFalse(self.execute('State X WHERE NOT X state_of WF'))
+ self.assertFalse(self.execute('Transition X WHERE NOT X transition_of WF'))
def test_add_drop_relation_type(self):
self.mh.cmd_add_entity_type('Folder2', auto=False)
self.mh.cmd_add_relation_type('filed_under2')
self.schema.rebuild_infered_relations()
- self.failUnless('filed_under2' in self.schema)
+ self.assertTrue('filed_under2' in self.schema)
self.assertEqual(sorted(str(e) for e in self.schema['filed_under2'].subjects()),
sorted(str(e) for e in self.schema.entities() if not e.final))
self.assertEqual(self.schema['filed_under2'].objects(), ('Folder2',))
self.mh.cmd_drop_relation_type('filed_under2')
- self.failIf('filed_under2' in self.schema)
+ self.assertFalse('filed_under2' in self.schema)
def test_add_relation_definition_nortype(self):
self.mh.cmd_add_relation_definition('Personne', 'concerne2', 'Affaire')
@@ -260,9 +260,9 @@
self.mh.rqlexec('SET X concerne2 Y WHERE X is Personne, Y is Affaire')
self.commit()
self.mh.cmd_drop_relation_definition('Personne', 'concerne2', 'Affaire')
- self.failUnless('concerne2' in self.schema)
+ self.assertTrue('concerne2' in self.schema)
self.mh.cmd_drop_relation_definition('Personne', 'concerne2', 'Note')
- self.failIf('concerne2' in self.schema)
+ self.assertFalse('concerne2' in self.schema)
def test_drop_relation_definition_existant_rtype(self):
self.assertEqual(sorted(str(e) for e in self.schema['concerne'].subjects()),
@@ -380,8 +380,8 @@
self.assertEqual(eexpr.reverse_delete_permission, ())
self.assertEqual(eexpr.reverse_update_permission, ())
# no more rqlexpr to delete and add para attribute
- self.failIf(self._rrqlexpr_rset('add', 'para'))
- self.failIf(self._rrqlexpr_rset('delete', 'para'))
+ self.assertFalse(self._rrqlexpr_rset('add', 'para'))
+ self.assertFalse(self._rrqlexpr_rset('delete', 'para'))
# new rql expr to add ecrit_par relation
rexpr = self._rrqlexpr_entity('add', 'ecrit_par')
self.assertEqual(rexpr.expression,
@@ -391,13 +391,13 @@
self.assertEqual(rexpr.reverse_read_permission, ())
self.assertEqual(rexpr.reverse_delete_permission, ())
# no more rqlexpr to delete and add travaille relation
- self.failIf(self._rrqlexpr_rset('add', 'travaille'))
- self.failIf(self._rrqlexpr_rset('delete', 'travaille'))
+ self.assertFalse(self._rrqlexpr_rset('add', 'travaille'))
+ self.assertFalse(self._rrqlexpr_rset('delete', 'travaille'))
# no more rqlexpr to delete and update Societe entity
- self.failIf(self._erqlexpr_rset('update', 'Societe'))
- self.failIf(self._erqlexpr_rset('delete', 'Societe'))
+ self.assertFalse(self._erqlexpr_rset('update', 'Societe'))
+ self.assertFalse(self._erqlexpr_rset('delete', 'Societe'))
# no more rqlexpr to read Affaire entity
- self.failIf(self._erqlexpr_rset('read', 'Affaire'))
+ self.assertFalse(self._erqlexpr_rset('read', 'Affaire'))
# rqlexpr to update Affaire entity has been updated
eexpr = self._erqlexpr_entity('update', 'Affaire')
self.assertEqual(eexpr.expression, 'X concerne S, S owned_by U')
@@ -470,13 +470,13 @@
try:
self.mh.cmd_remove_cube('email', removedeps=True)
# file was there because it's an email dependancy, should have been removed
- self.failIf('email' in self.config.cubes())
- self.failIf(self.config.cube_dir('email') in self.config.cubes_path())
- self.failIf('file' in self.config.cubes())
- self.failIf(self.config.cube_dir('file') in self.config.cubes_path())
+ self.assertFalse('email' in self.config.cubes())
+ self.assertFalse(self.config.cube_dir('email') in self.config.cubes_path())
+ self.assertFalse('file' in self.config.cubes())
+ self.assertFalse(self.config.cube_dir('file') in self.config.cubes_path())
for ertype in ('Email', 'EmailThread', 'EmailPart', 'File',
'sender', 'in_thread', 'reply_to', 'data_format'):
- self.failIf(ertype in schema, ertype)
+ self.assertFalse(ertype in schema, ertype)
self.assertEqual(sorted(schema['see_also'].rdefs.keys()),
sorted([('Folder', 'Folder'),
('Bookmark', 'Bookmark'),
@@ -493,13 +493,13 @@
raise
finally:
self.mh.cmd_add_cube('email')
- self.failUnless('email' in self.config.cubes())
- self.failUnless(self.config.cube_dir('email') in self.config.cubes_path())
- self.failUnless('file' in self.config.cubes())
- self.failUnless(self.config.cube_dir('file') in self.config.cubes_path())
+ self.assertTrue('email' in self.config.cubes())
+ self.assertTrue(self.config.cube_dir('email') in self.config.cubes_path())
+ self.assertTrue('file' in self.config.cubes())
+ self.assertTrue(self.config.cube_dir('file') in self.config.cubes_path())
for ertype in ('Email', 'EmailThread', 'EmailPart', 'File',
'sender', 'in_thread', 'reply_to', 'data_format'):
- self.failUnless(ertype in schema, ertype)
+ self.assertTrue(ertype in schema, ertype)
self.assertEqual(sorted(schema['see_also'].rdefs.keys()),
sorted([('EmailThread', 'EmailThread'), ('Folder', 'Folder'),
('Bookmark', 'Bookmark'),
@@ -530,18 +530,18 @@
try:
self.mh.cmd_remove_cube('email')
cubes.remove('email')
- self.failIf('email' in self.config.cubes())
- self.failUnless('file' in self.config.cubes())
+ self.assertFalse('email' in self.config.cubes())
+ self.assertTrue('file' in self.config.cubes())
for ertype in ('Email', 'EmailThread', 'EmailPart',
'sender', 'in_thread', 'reply_to'):
- self.failIf(ertype in schema, ertype)
+ self.assertFalse(ertype in schema, ertype)
except :
import traceback
traceback.print_exc()
raise
finally:
self.mh.cmd_add_cube('email')
- self.failUnless('email' in self.config.cubes())
+ self.assertTrue('email' in self.config.cubes())
# trick: overwrite self.maxeid to avoid deletion of just reintroduced
# types (and their associated tables!)
self.maxeid = self.execute('Any MAX(X)')[0][0]
@@ -570,13 +570,13 @@
text = self.execute('INSERT Text X: X para "hip", X summary "hop", X newattr "momo"').get_entity(0, 0)
note = self.execute('INSERT Note X: X para "hip", X shortpara "hop", X newattr "momo", X unique_id "x"').get_entity(0, 0)
aff = self.execute('INSERT Affaire X').get_entity(0, 0)
- self.failUnless(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s',
+ self.assertTrue(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s',
{'x': text.eid, 'y': aff.eid}))
- self.failUnless(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s',
+ self.assertTrue(self.execute('SET X newnotinlined Y WHERE X eid %(x)s, Y eid %(y)s',
{'x': note.eid, 'y': aff.eid}))
- self.failUnless(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s',
+ self.assertTrue(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s',
{'x': text.eid, 'y': aff.eid}))
- self.failUnless(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s',
+ self.assertTrue(self.execute('SET X newinlined Y WHERE X eid %(x)s, Y eid %(y)s',
{'x': note.eid, 'y': aff.eid}))
# XXX remove specializes by ourselves, else tearDown fails when removing
# Para because of Note inheritance. This could be fixed by putting the
@@ -601,11 +601,11 @@
def test_add_symmetric_relation_type(self):
same_as_sql = self.mh.sqlexec("SELECT sql FROM sqlite_master WHERE type='table' "
"and name='same_as_relation'")
- self.failIf(same_as_sql)
+ self.assertFalse(same_as_sql)
self.mh.cmd_add_relation_type('same_as')
same_as_sql = self.mh.sqlexec("SELECT sql FROM sqlite_master WHERE type='table' "
"and name='same_as_relation'")
- self.failUnless(same_as_sql)
+ self.assertTrue(same_as_sql)
if __name__ == '__main__':
unittest_main()
--- a/server/test/unittest_multisources.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_multisources.py Wed Sep 14 09:11:50 2011 +0200
@@ -180,10 +180,10 @@
def test_has_text(self):
self.repo.sources_by_uri['extern'].synchronize(MTIME) # in case fti_update has been run before
- self.failUnless(self.sexecute('Any X WHERE X has_text "affref"'))
- self.failUnless(self.sexecute('Affaire X WHERE X has_text "affref"'))
- self.failUnless(self.sexecute('Any X ORDERBY FTIRANK(X) WHERE X has_text "affref"'))
- self.failUnless(self.sexecute('Affaire X ORDERBY FTIRANK(X) WHERE X has_text "affref"'))
+ self.assertTrue(self.sexecute('Any X WHERE X has_text "affref"'))
+ self.assertTrue(self.sexecute('Affaire X WHERE X has_text "affref"'))
+ self.assertTrue(self.sexecute('Any X ORDERBY FTIRANK(X) WHERE X has_text "affref"'))
+ self.assertTrue(self.sexecute('Affaire X ORDERBY FTIRANK(X) WHERE X has_text "affref"'))
def test_anon_has_text(self):
self.repo.sources_by_uri['extern'].synchronize(MTIME) # in case fti_update has been run before
@@ -210,13 +210,13 @@
try:
# force sync
self.repo.sources_by_uri['extern'].synchronize(MTIME)
- self.failUnless(self.sexecute('Any X WHERE X has_text "blah"'))
- self.failUnless(self.sexecute('Any X WHERE X has_text "affreux"'))
+ self.assertTrue(self.sexecute('Any X WHERE X has_text "blah"'))
+ self.assertTrue(self.sexecute('Any X WHERE X has_text "affreux"'))
cu.execute('DELETE Affaire X WHERE X eid %(x)s', {'x': aff2})
self.cnx2.commit()
self.repo.sources_by_uri['extern'].synchronize(MTIME)
rset = self.sexecute('Any X WHERE X has_text "affreux"')
- self.failIf(rset)
+ self.assertFalse(rset)
finally:
# restore state
cu.execute('SET X ref "AFFREF" WHERE X eid %(x)s', {'x': self.aff1})
@@ -389,7 +389,7 @@
req.execute('DELETE CWSource S WHERE S name "extern"')
self.commit()
cu = self.session.system_sql("SELECT * FROM entities WHERE source='extern'")
- self.failIf(cu.fetchall())
+ self.assertFalse(cu.fetchall())
if __name__ == '__main__':
from logilab.common.testlib import unittest_main
--- 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):
--- a/server/test/unittest_repository.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_repository.py Wed Sep 14 09:11:50 2011 +0200
@@ -98,13 +98,13 @@
('nom', 'prenom', 'inline2'))
def test_all_entities_have_owner(self):
- self.failIf(self.execute('Any X WHERE NOT X owned_by U'))
+ self.assertFalse(self.execute('Any X WHERE NOT X owned_by U'))
def test_all_entities_have_is(self):
- self.failIf(self.execute('Any X WHERE NOT X is ET'))
+ self.assertFalse(self.execute('Any X WHERE NOT X is ET'))
def test_all_entities_have_cw_source(self):
- self.failIf(self.execute('Any X WHERE NOT X cw_source S'))
+ self.assertFalse(self.execute('Any X WHERE NOT X cw_source S'))
def test_connect(self):
cnxid = self.repo.connect(self.admlogin, password=self.admpassword)
@@ -147,7 +147,7 @@
'INSERT CWUser X: X login %(login)s, X upassword %(passwd)s',
{'login': u"tutetute", 'passwd': 'tutetute'})
self.assertRaises(ValidationError, self.repo.commit, cnxid)
- self.failIf(self.repo.execute(cnxid, 'CWUser X WHERE X login "tutetute"'))
+ self.assertFalse(self.repo.execute(cnxid, 'CWUser X WHERE X login "tutetute"'))
self.repo.close(cnxid)
def test_rollback_on_execute_validation_error(self):
@@ -160,12 +160,12 @@
with self.temporary_appobjects(ValidationErrorAfterHook):
self.assertRaises(ValidationError,
self.execute, 'SET X name "toto" WHERE X is CWGroup, X name "guests"')
- self.failUnless(self.execute('Any X WHERE X is CWGroup, X name "toto"'))
+ self.assertTrue(self.execute('Any X WHERE X is CWGroup, X name "toto"'))
with self.assertRaises(QueryError) as cm:
self.commit()
self.assertEqual(str(cm.exception), 'transaction must be rollbacked')
self.rollback()
- self.failIf(self.execute('Any X WHERE X is CWGroup, X name "toto"'))
+ self.assertFalse(self.execute('Any X WHERE X is CWGroup, X name "toto"'))
def test_rollback_on_execute_unauthorized(self):
class UnauthorizedAfterHook(Hook):
@@ -177,12 +177,12 @@
with self.temporary_appobjects(UnauthorizedAfterHook):
self.assertRaises(Unauthorized,
self.execute, 'SET X name "toto" WHERE X is CWGroup, X name "guests"')
- self.failUnless(self.execute('Any X WHERE X is CWGroup, X name "toto"'))
+ self.assertTrue(self.execute('Any X WHERE X is CWGroup, X name "toto"'))
with self.assertRaises(QueryError) as cm:
self.commit()
self.assertEqual(str(cm.exception), 'transaction must be rollbacked')
self.rollback()
- self.failIf(self.execute('Any X WHERE X is CWGroup, X name "toto"'))
+ self.assertFalse(self.execute('Any X WHERE X is CWGroup, X name "toto"'))
def test_close(self):
@@ -364,13 +364,13 @@
cnx.load_appobjects(subpath=('entities',))
# check we can get the schema
schema = cnx.get_schema()
- self.failUnless(cnx.vreg)
- self.failUnless('etypes'in cnx.vreg)
+ self.assertTrue(cnx.vreg)
+ self.assertTrue('etypes'in cnx.vreg)
cu = cnx.cursor()
rset = cu.execute('Any U,G WHERE U in_group G')
user = iter(rset.entities()).next()
- self.failUnless(user._cw)
- self.failUnless(user._cw.vreg)
+ self.assertTrue(user._cw)
+ self.assertTrue(user._cw.vreg)
from cubicweb.entities import authobjs
self.assertIsInstance(user._cw.user, authobjs.CWUser)
cnx.close()
@@ -425,7 +425,7 @@
def test_schema_is_relation(self):
no_is_rset = self.execute('Any X WHERE NOT X is ET')
- self.failIf(no_is_rset, no_is_rset.description)
+ self.assertFalse(no_is_rset, no_is_rset.description)
# def test_perfo(self):
# self.set_debug(True)
@@ -509,7 +509,7 @@
events = ('before_update_entity',)
def __call__(self):
# invoiced attribute shouldn't be considered "edited" before the hook
- self._test.failIf('invoiced' in self.entity.cw_edited,
+ self._test.assertFalse('invoiced' in self.entity.cw_edited,
'cw_edited cluttered by previous update')
self.entity.cw_edited['invoiced'] = 10
with self.temporary_appobjects(DummyBeforeHook):
@@ -582,7 +582,7 @@
self.session.set_cnxset()
cu = self.session.system_sql('SELECT mtime FROM entities WHERE eid = %s' % eidp)
mtime = cu.fetchone()[0]
- self.failUnless(omtime < mtime)
+ self.assertTrue(omtime < mtime)
self.commit()
date, modified, deleted = self.repo.entities_modified_since(('Personne',), omtime)
self.assertEqual(modified, [('Personne', eidp)])
@@ -627,7 +627,7 @@
def test_no_uncessary_ftiindex_op(self):
req = self.request()
req.create_entity('Workflow', name=u'dummy workflow', description=u'huuuuu')
- self.failIf(any(x for x in self.session.pending_operations
+ self.assertFalse(any(x for x in self.session.pending_operations
if isinstance(x, native.FTIndexEntityOp)))
--- a/server/test/unittest_rqlannotation.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_rqlannotation.py Wed Sep 14 09:11:50 2011 +0200
@@ -342,7 +342,7 @@
def test_remove_from_deleted_source_1(self):
rqlst = self._prepare('Note X WHERE X eid 999998, NOT X cw_source Y')
- self.failIf('X' in rqlst.defined_vars) # simplified
+ self.assertFalse('X' in rqlst.defined_vars) # simplified
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True)
def test_remove_from_deleted_source_2(self):
--- a/server/test/unittest_security.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_security.py Wed Sep 14 09:11:50 2011 +0200
@@ -327,7 +327,7 @@
cu = cnx.cursor()
aff2 = cu.execute("INSERT Affaire X: X sujet 'cool'")[0][0]
# entity created in transaction are readable *by eid*
- self.failUnless(cu.execute('Any X WHERE X eid %(x)s', {'x':aff2}))
+ self.assertTrue(cu.execute('Any X WHERE X eid %(x)s', {'x':aff2}))
# XXX would be nice if it worked
rset = cu.execute("Affaire X WHERE X sujet 'cool'")
self.assertEqual(len(rset), 0)
@@ -347,8 +347,8 @@
cu.execute("SET A concerne S WHERE A eid %(a)s, S eid %(s)s", {'a': aff2, 's': soc1})
cnx.commit()
self.assertRaises(Unauthorized, cu.execute, 'Any X WHERE X eid %(x)s', {'x':aff1})
- self.failUnless(cu.execute('Any X WHERE X eid %(x)s', {'x':aff2}))
- self.failUnless(cu.execute('Any X WHERE X eid %(x)s', {'x':card1}))
+ self.assertTrue(cu.execute('Any X WHERE X eid %(x)s', {'x':aff2}))
+ self.assertTrue(cu.execute('Any X WHERE X eid %(x)s', {'x':card1}))
rset = cu.execute("Any X WHERE X has_text 'cool'")
self.assertEqual(sorted(eid for eid, in rset.rows),
[card1, aff2])
@@ -457,14 +457,14 @@
cnx = self.login('anon')
cu = cnx.cursor()
rset = cu.execute('CWUser X')
- self.failUnless(rset)
+ self.assertTrue(rset)
x = rset.get_entity(0, 0)
self.assertEqual(x.login, None)
- self.failUnless(x.creation_date)
+ self.assertTrue(x.creation_date)
x = rset.get_entity(1, 0)
x.complete()
self.assertEqual(x.login, None)
- self.failUnless(x.creation_date)
+ self.assertTrue(x.creation_date)
cnx.rollback()
cnx.close()
@@ -492,7 +492,7 @@
cu = cnx.cursor()
cu.execute('DELETE Affaire X WHERE X ref "ARCT01"')
cnx.commit()
- self.failIf(cu.execute('Affaire X'))
+ self.assertFalse(cu.execute('Affaire X'))
cnx.close()
def test_users_and_groups_non_readable_by_guests(self):
--- a/server/test/unittest_session.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_session.py Wed Sep 14 09:11:50 2011 +0200
@@ -95,7 +95,7 @@
description = self.session.build_description(rset.syntax_tree(), None, rset.rows)
self.assertEqual(len(description), orig_length - 1)
self.assertEqual(len(rset.rows), orig_length - 1)
- self.failIf(rset.rows[0][0] == 9999999)
+ self.assertFalse(rset.rows[0][0] == 9999999)
if __name__ == '__main__':
--- a/server/test/unittest_storage.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_storage.py Wed Sep 14 09:11:50 2011 +0200
@@ -89,10 +89,10 @@
f1 = self.create_file()
expected_filepath = osp.join(self.tempdir, '%s_data_%s' %
(f1.eid, f1.data_name))
- self.failUnless(osp.isfile(expected_filepath))
+ self.assertTrue(osp.isfile(expected_filepath))
self.assertEqual(file(expected_filepath).read(), 'the-data')
self.rollback()
- self.failIf(osp.isfile(expected_filepath))
+ self.assertFalse(osp.isfile(expected_filepath))
f1 = self.create_file()
self.commit()
self.assertEqual(file(expected_filepath).read(), 'the-data')
@@ -100,12 +100,12 @@
self.rollback()
self.assertEqual(file(expected_filepath).read(), 'the-data')
f1.cw_delete()
- self.failUnless(osp.isfile(expected_filepath))
+ self.assertTrue(osp.isfile(expected_filepath))
self.rollback()
- self.failUnless(osp.isfile(expected_filepath))
+ self.assertTrue(osp.isfile(expected_filepath))
f1.cw_delete()
self.commit()
- self.failIf(osp.isfile(expected_filepath))
+ self.assertFalse(osp.isfile(expected_filepath))
def test_bfss_sqlite_fspath(self):
f1 = self.create_file()
@@ -219,7 +219,7 @@
# update f1's local dict. We want the pure rql version to work
self.commit()
old_path = self.fspath(f1)
- self.failUnless(osp.isfile(old_path))
+ self.assertTrue(osp.isfile(old_path))
self.assertEqual(osp.splitext(old_path)[1], '.txt')
self.execute('SET F data %(d)s, F data_name %(dn)s, F data_format %(df)s WHERE F eid %(f)s',
{'d': Binary('some other data'), 'f': f1.eid, 'dn': u'bar.jpg', 'df': u'image/jpeg'})
@@ -228,8 +228,8 @@
# the old file is dead
f2 = self.execute('Any F WHERE F eid %(f)s, F is File', {'f': f1.eid}).get_entity(0, 0)
new_path = self.fspath(f2)
- self.failIf(osp.isfile(old_path))
- self.failUnless(osp.isfile(new_path))
+ self.assertFalse(osp.isfile(old_path))
+ self.assertTrue(osp.isfile(new_path))
self.assertEqual(osp.splitext(new_path)[1], '.jpg')
@tag('update', 'extension', 'rollback')
@@ -242,7 +242,7 @@
self.commit()
old_path = self.fspath(f1)
old_data = f1.data.getvalue()
- self.failUnless(osp.isfile(old_path))
+ self.assertTrue(osp.isfile(old_path))
self.assertEqual(osp.splitext(old_path)[1], '.txt')
self.execute('SET F data %(d)s, F data_name %(dn)s, F data_format %(df)s WHERE F eid %(f)s',
{'d': Binary('some other data'), 'f': f1.eid, 'dn': u'bar.jpg', 'df': u'image/jpeg'})
@@ -252,7 +252,7 @@
f2 = self.execute('Any F WHERE F eid %(f)s, F is File', {'f': f1.eid}).get_entity(0, 0)
new_path = self.fspath(f2)
new_data = f2.data.getvalue()
- self.failUnless(osp.isfile(new_path))
+ self.assertTrue(osp.isfile(new_path))
self.assertEqual(osp.splitext(new_path)[1], '.txt')
self.assertEqual(old_path, new_path)
self.assertEqual(old_data, new_data)
@@ -279,7 +279,7 @@
self.commit()
self.assertEqual(f1.data.getvalue(), 'the new data')
self.assertEqual(self.fspath(f1), new_fspath)
- self.failIf(osp.isfile(old_fspath))
+ self.assertFalse(osp.isfile(old_fspath))
@tag('fsimport')
def test_clean(self):
--- a/server/test/unittest_undo.py Wed Sep 14 09:10:58 2011 +0200
+++ b/server/test/unittest_undo.py Wed Sep 14 09:11:50 2011 +0200
@@ -43,13 +43,13 @@
# also check transaction actions have been properly deleted
cu = self.session.system_sql(
"SELECT * from tx_entity_actions WHERE tx_uuid='%s'" % txuuid)
- self.failIf(cu.fetchall())
+ self.assertFalse(cu.fetchall())
cu = self.session.system_sql(
"SELECT * from tx_relation_actions WHERE tx_uuid='%s'" % txuuid)
- self.failIf(cu.fetchall())
+ self.assertFalse(cu.fetchall())
def test_undo_api(self):
- self.failUnless(self.txuuid)
+ self.assertTrue(self.txuuid)
# test transaction api
self.assertRaises(NoSuchTransaction,
self.cnx.transaction_info, 'hop')
@@ -58,7 +58,7 @@
self.assertRaises(NoSuchTransaction,
self.cnx.undo_transaction, 'hop')
txinfo = self.cnx.transaction_info(self.txuuid)
- self.failUnless(txinfo.datetime)
+ self.assertTrue(txinfo.datetime)
self.assertEqual(txinfo.user_eid, self.session.user.eid)
self.assertEqual(txinfo.user().login, 'admin')
actions = txinfo.actions_list()
@@ -159,9 +159,9 @@
undotxuuid = self.commit()
self.assertEqual(undotxuuid, None) # undo not undoable
self.assertEqual(errors, [])
- self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': toto.eid}))
- self.failUnless(self.execute('Any X WHERE X eid %(x)s', {'x': e.eid}))
- self.failUnless(self.execute('Any X WHERE X has_text "toto@logilab"'))
+ self.assertTrue(self.execute('Any X WHERE X eid %(x)s', {'x': toto.eid}))
+ self.assertTrue(self.execute('Any X WHERE X eid %(x)s', {'x': e.eid}))
+ self.assertTrue(self.execute('Any X WHERE X has_text "toto@logilab"'))
self.assertEqual(toto.cw_adapt_to('IWorkflowable').state, 'activated')
self.assertEqual(toto.cw_adapt_to('IEmailable').get_email(), 'toto@logilab.org')
self.assertEqual([(p.pkey, p.value) for p in toto.reverse_for_user],
@@ -231,20 +231,20 @@
txuuid = self.commit()
errors = self.cnx.undo_transaction(txuuid)
self.commit()
- self.failIf(errors)
- self.failIf(self.execute('Any X WHERE X eid %(x)s', {'x': c.eid}))
- self.failIf(self.execute('Any X WHERE X eid %(x)s', {'x': p.eid}))
- self.failIf(self.execute('Any X,Y WHERE X fiche Y'))
+ self.assertFalse(errors)
+ self.assertFalse(self.execute('Any X WHERE X eid %(x)s', {'x': c.eid}))
+ self.assertFalse(self.execute('Any X WHERE X eid %(x)s', {'x': p.eid}))
+ self.assertFalse(self.execute('Any X,Y WHERE X fiche Y'))
self.session.set_cnxset()
for eid in (p.eid, c.eid):
- self.failIf(session.system_sql(
+ self.assertFalse(session.system_sql(
'SELECT * FROM entities WHERE eid=%s' % eid).fetchall())
- self.failIf(session.system_sql(
+ self.assertFalse(session.system_sql(
'SELECT 1 FROM owned_by_relation WHERE eid_from=%s' % eid).fetchall())
# added by sql in hooks (except when using dataimport)
- self.failIf(session.system_sql(
+ self.assertFalse(session.system_sql(
'SELECT 1 FROM is_relation WHERE eid_from=%s' % eid).fetchall())
- self.failIf(session.system_sql(
+ self.assertFalse(session.system_sql(
'SELECT 1 FROM is_instance_of_relation WHERE eid_from=%s' % eid).fetchall())
self.check_transaction_deleted(txuuid)
--- a/sobjects/test/unittest_email.py Wed Sep 14 09:10:58 2011 +0200
+++ b/sobjects/test/unittest_email.py Wed Sep 14 09:11:50 2011 +0200
@@ -51,7 +51,7 @@
self.execute('SET U primary_email E WHERE U login "anon", E address "client@client.com"')
self.commit()
rset = self.execute('Any X WHERE X use_email E, E eid %(e)s', {'e': email1})
- self.failIf(rset.rowcount != 1, rset)
+ self.assertFalse(rset.rowcount != 1, rset)
def test_security_check(self):
req = self.request()
--- a/sobjects/test/unittest_notification.py Wed Sep 14 09:10:58 2011 +0200
+++ b/sobjects/test/unittest_notification.py Wed Sep 14 09:11:50 2011 +0200
@@ -30,29 +30,29 @@
def test_base(self):
msgid1 = construct_message_id('testapp', 21)
msgid2 = construct_message_id('testapp', 21)
- self.failIfEqual(msgid1, msgid2)
- self.failIf('&' in msgid1)
- self.failIf('=' in msgid1)
- self.failIf('/' in msgid1)
- self.failIf('+' in msgid1)
+ self.assertNotEqual(msgid1, msgid2)
+ self.assertFalse('&' in msgid1)
+ self.assertFalse('=' in msgid1)
+ self.assertFalse('/' in msgid1)
+ self.assertFalse('+' in msgid1)
values = parse_message_id(msgid1, 'testapp')
- self.failUnless(values)
+ self.assertTrue(values)
# parse_message_id should work with or without surrounding <>
- self.failUnlessEqual(values, parse_message_id(msgid1[1:-1], 'testapp'))
- self.failUnlessEqual(values['eid'], '21')
- self.failUnless('timestamp' in values)
- self.failUnlessEqual(parse_message_id(msgid1[1:-1], 'anotherapp'), None)
+ self.assertEqual(values, parse_message_id(msgid1[1:-1], 'testapp'))
+ self.assertEqual(values['eid'], '21')
+ self.assertTrue('timestamp' in values)
+ self.assertEqual(parse_message_id(msgid1[1:-1], 'anotherapp'), None)
def test_notimestamp(self):
msgid1 = construct_message_id('testapp', 21, False)
msgid2 = construct_message_id('testapp', 21, False)
values = parse_message_id(msgid1, 'testapp')
- self.failUnlessEqual(values, {'eid': '21'})
+ self.assertEqual(values, {'eid': '21'})
def test_parse_message_doesnt_raise(self):
- self.failUnlessEqual(parse_message_id('oijioj@bla.bla', 'tesapp'), None)
- self.failUnlessEqual(parse_message_id('oijioj@bla', 'tesapp'), None)
- self.failUnlessEqual(parse_message_id('oijioj', 'tesapp'), None)
+ self.assertEqual(parse_message_id('oijioj@bla.bla', 'tesapp'), None)
+ self.assertEqual(parse_message_id('oijioj@bla', 'tesapp'), None)
+ self.assertEqual(parse_message_id('oijioj', 'tesapp'), None)
def test_nonregr_empty_message_id(self):
@@ -86,7 +86,7 @@
req = self.request()
u = self.create_user(req, 'toto')
u.cw_adapt_to('IWorkflowable').fire_transition('deactivate', comment=u'yeah')
- self.failIf(MAILBOX)
+ self.assertFalse(MAILBOX)
self.commit()
self.assertEqual(len(MAILBOX), 1)
email = MAILBOX[0]
--- a/test/unittest_cwconfig.py Wed Sep 14 09:10:58 2011 +0200
+++ b/test/unittest_cwconfig.py Wed Sep 14 09:11:50 2011 +0200
@@ -123,7 +123,7 @@
self.assertEqual(self.config.cubes_search_path(),
[CUSTOM_CUBES_DIR,
self.config.CUBES_DIR])
- self.failUnless('mycube' in self.config.available_cubes())
+ self.assertTrue('mycube' in self.config.available_cubes())
# test cubes python path
self.config.adjust_sys_path()
import cubes
--- a/test/unittest_entity.py Wed Sep 14 09:10:58 2011 +0200
+++ b/test/unittest_entity.py Wed Sep 14 09:11:50 2011 +0200
@@ -42,7 +42,7 @@
def test_boolean_value(self):
e = self.vreg['etypes'].etype_class('CWUser')(self.request())
- self.failUnless(e)
+ self.assertTrue(e)
def test_yams_inheritance(self):
from entities import Note
@@ -87,8 +87,8 @@
{'t': oe.eid, 'u': p.eid})
e = req.create_entity('Note', type=u'z')
e.copy_relations(oe.eid)
- self.failIf(e.ecrit_par)
- self.failUnless(oe.ecrit_par)
+ self.assertFalse(e.ecrit_par)
+ self.assertTrue(oe.ecrit_par)
def test_copy_with_composite(self):
user = self.user()
@@ -100,8 +100,8 @@
'WHERE G name "users"')[0][0]
e = self.execute('Any X WHERE X eid %(x)s', {'x': usereid}).get_entity(0, 0)
e.copy_relations(user.eid)
- self.failIf(e.use_email)
- self.failIf(e.primary_email)
+ self.assertFalse(e.use_email)
+ self.assertFalse(e.primary_email)
def test_copy_with_non_initial_state(self):
user = self.user()
@@ -128,7 +128,7 @@
groups = user.in_group
self.assertEqual(sorted(user._cw_related_cache), ['in_group_subject', 'primary_email_subject'])
for group in groups:
- self.failIf('in_group_subject' in group._cw_related_cache, group._cw_related_cache.keys())
+ self.assertFalse('in_group_subject' in group._cw_related_cache, group._cw_related_cache.keys())
def test_related_limit(self):
req = self.request()
@@ -227,7 +227,7 @@
Personne = self.vreg['etypes'].etype_class('Personne')
Note = self.vreg['etypes'].etype_class('Note')
SubNote = self.vreg['etypes'].etype_class('SubNote')
- self.failUnless(issubclass(self.vreg['etypes'].etype_class('SubNote'), Note))
+ self.assertTrue(issubclass(self.vreg['etypes'].etype_class('SubNote'), Note))
Personne.fetch_attrs, Personne.fetch_order = fetch_config(('nom', 'type'))
Note.fetch_attrs, Note.fetch_order = fetch_config(('type',))
SubNote.fetch_attrs, SubNote.fetch_order = fetch_config(('type',))
@@ -364,13 +364,13 @@
p = req.create_entity('Personne', nom=u'di mascio', prenom=u'adrien')
e = req.create_entity('Tag', name=u'x')
related = [r.eid for r in e.tags]
- self.failUnlessEqual(related, [])
+ self.assertEqual(related, [])
unrelated = [r[0] for r in e.unrelated('tags', 'Personne', 'subject')]
- self.failUnless(p.eid in unrelated)
+ self.assertTrue(p.eid in unrelated)
self.execute('SET X tags Y WHERE X is Tag, Y is Personne')
e = self.execute('Any X WHERE X is Tag').get_entity(0, 0)
unrelated = [r[0] for r in e.unrelated('tags', 'Personne', 'subject')]
- self.failIf(p.eid in unrelated)
+ self.assertFalse(p.eid in unrelated)
def test_unrelated_limit(self):
req = self.request()
@@ -538,7 +538,7 @@
p2 = req.create_entity('Personne', nom=u'toto')
self.execute('SET X evaluee Y WHERE X nom "di mascio", Y nom "toto"')
self.assertEqual(p1.evaluee[0].nom, "toto")
- self.failUnless(not p1.reverse_evaluee)
+ self.assertTrue(not p1.reverse_evaluee)
def test_complete_relation(self):
session = self.session
@@ -547,10 +547,10 @@
'WHERE U login "admin", S1 name "activated", S2 name "deactivated"')[0][0]
trinfo = self.execute('Any X WHERE X eid %(x)s', {'x': eid}).get_entity(0, 0)
trinfo.complete()
- self.failUnless(isinstance(trinfo.cw_attr_cache['creation_date'], datetime))
- self.failUnless(trinfo.cw_relation_cached('from_state', 'subject'))
- self.failUnless(trinfo.cw_relation_cached('to_state', 'subject'))
- self.failUnless(trinfo.cw_relation_cached('wf_info_for', 'subject'))
+ self.assertTrue(isinstance(trinfo.cw_attr_cache['creation_date'], datetime))
+ self.assertTrue(trinfo.cw_relation_cached('from_state', 'subject'))
+ self.assertTrue(trinfo.cw_relation_cached('to_state', 'subject'))
+ self.assertTrue(trinfo.cw_relation_cached('wf_info_for', 'subject'))
self.assertEqual(trinfo.by_transition, ())
def test_request_cache(self):
@@ -558,7 +558,7 @@
user = self.execute('CWUser X WHERE X login "admin"', req=req).get_entity(0, 0)
state = user.in_state[0]
samestate = self.execute('State X WHERE X name "activated"', req=req).get_entity(0, 0)
- self.failUnless(state is samestate)
+ self.assertTrue(state is samestate)
def test_rest_path(self):
req = self.request()
--- a/test/unittest_rqlrewrite.py Wed Sep 14 09:10:58 2011 +0200
+++ b/test/unittest_rqlrewrite.py Wed Sep 14 09:11:50 2011 +0200
@@ -110,7 +110,7 @@
'P name "read", P require_group G')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'X'): (constraint,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any C WHERE C is Card, B eid %(D)s, "
"EXISTS(C in_state A, B in_group E, F require_state A, "
"F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission)")
@@ -129,13 +129,13 @@
"F name 'read', F require_group E, A is State, E is CWGroup, F is CWPermission), "
"(EXISTS(S ref LIKE 'PUBLIC%')) OR (EXISTS(B in_group G, G name 'public', G is CWGroup)), "
"S is Affaire")
- self.failUnless('D' in kwargs)
+ self.assertTrue('D' in kwargs)
def test_or(self):
constraint = '(X identity U) OR (X in_state ST, CL identity U, CL in_state ST, ST name "subscribed")'
rqlst = parse('Any S WHERE S owned_by C, C eid %(u)s, S is in (CWUser, CWGroup)')
rewrite(rqlst, {('C', 'X'): (constraint,)}, {'u':1})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any S WHERE S owned_by C, C eid %(u)s, S is IN(CWUser, CWGroup), A eid %(B)s, "
"EXISTS((C identity A) OR (C in_state D, E identity A, "
"E in_state D, D name 'subscribed'), D is State, E is CWUser)")
@@ -145,7 +145,7 @@
'P name "read", P require_group G')
rqlst = parse('Any 2') # this is the simplified rql st for Any X WHERE X eid 12
rewrite(rqlst, {('2', 'X'): (constraint,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any 2 WHERE B eid %(C)s, "
"EXISTS(2 in_state A, B in_group D, E require_state A, "
"E name 'read', E require_group D, A is State, D is CWGroup, E is CWPermission)")
@@ -155,7 +155,7 @@
'P name "read", P require_group G')
rqlst = parse('Any A,C WHERE A documented_by C?')
rewrite(rqlst, {('C', 'X'): (constraint,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any A,C WHERE A documented_by C?, A is Affaire "
"WITH C BEING "
"(Any C WHERE EXISTS(C in_state B, D in_group F, G require_state B, G name 'read', "
@@ -166,7 +166,7 @@
'P name "read", P require_group G')
rqlst = parse('Any A,C,T WHERE A documented_by C?, C title T')
rewrite(rqlst, {('C', 'X'): (constraint,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any A,C,T WHERE A documented_by C?, A is Affaire "
"WITH C,T BEING "
"(Any C,T WHERE C title T, EXISTS(C in_state B, D in_group F, "
@@ -179,7 +179,7 @@
constraint2 = 'X in_state S, S name "public"'
rqlst = parse('Any A,C,T WHERE A documented_by C?, C title T')
rewrite(rqlst, {('C', 'X'): (constraint1, constraint2)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any A,C,T WHERE A documented_by C?, A is Affaire "
"WITH C,T BEING (Any C,T WHERE C title T, "
"EXISTS(C in_state B, D in_group F, G require_state B, G name 'read', G require_group F), "
@@ -194,7 +194,7 @@
rewrite(rqlst, {('LA', 'X'): (constraint1, constraint2),
('X', 'X'): (constraint3,),
('Y', 'X'): (constraint3,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u'Any X,LA,Y WHERE LA? documented_by X, LA concerne Y, B eid %(C)s, '
'EXISTS(X created_by B), EXISTS(Y created_by B), '
'X is Card, Y is IN(Division, Note, Societe) '
@@ -223,7 +223,7 @@
# rewrite(rqlst, {('C', 'X'): (c1,),
# ('A', 'X'): (c2,),
# }, {})
- # self.failUnlessEqual(rqlst.as_string(),
+ # self.assertEqual(rqlst.as_string(),
# "")
def test_optional_var_inlined_imbricated_error(self):
@@ -243,14 +243,14 @@
snippet = ('X in_state S, S name "hop"')
rqlst = parse('Card C WHERE C in_state STATE')
rewrite(rqlst, {('C', 'X'): (snippet,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any C WHERE C in_state STATE, C is Card, "
"EXISTS(STATE name 'hop'), STATE is State")
def test_relation_optimization_1_rhs(self):
snippet = ('TW subworkflow_exit X, TW name "hop"')
rqlst = parse('WorkflowTransition C WHERE C subworkflow_exit EXIT')
rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any C WHERE C subworkflow_exit EXIT, C is WorkflowTransition, "
"EXISTS(C name 'hop'), EXIT is SubWorkflowExitPoint")
@@ -259,14 +259,14 @@
snippet = ('X in_state S?, S name "hop"')
rqlst = parse('Card C WHERE C in_state STATE?')
rewrite(rqlst, {('C', 'X'): (snippet,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any C WHERE C in_state STATE?, C is Card, "
"EXISTS(STATE name 'hop'), STATE is State")
def test_relation_optimization_2_rhs(self):
snippet = ('TW? subworkflow_exit X, TW name "hop"')
rqlst = parse('SubWorkflowExitPoint EXIT WHERE C? subworkflow_exit EXIT')
rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any EXIT WHERE C? subworkflow_exit EXIT, EXIT is SubWorkflowExitPoint, "
"EXISTS(C name 'hop'), C is WorkflowTransition")
@@ -275,14 +275,14 @@
snippet = ('X in_state S?, S name "hop"')
rqlst = parse('Card C WHERE C in_state STATE')
rewrite(rqlst, {('C', 'X'): (snippet,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any C WHERE C in_state STATE, C is Card, "
"EXISTS(STATE name 'hop'), STATE is State")
def test_relation_optimization_3_rhs(self):
snippet = ('TW? subworkflow_exit X, TW name "hop"')
rqlst = parse('WorkflowTransition C WHERE C subworkflow_exit EXIT')
rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any C WHERE C subworkflow_exit EXIT, C is WorkflowTransition, "
"EXISTS(C name 'hop'), EXIT is SubWorkflowExitPoint")
@@ -291,14 +291,14 @@
snippet = ('X in_state S, S name "hop"')
rqlst = parse('Card C WHERE C in_state STATE?')
rewrite(rqlst, {('C', 'X'): (snippet,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any C WHERE C in_state STATE?, C is Card, "
"EXISTS(C in_state A, A name 'hop', A is State), STATE is State")
def test_relation_non_optimization_1_rhs(self):
snippet = ('TW subworkflow_exit X, TW name "hop"')
rqlst = parse('SubWorkflowExitPoint EXIT WHERE C? subworkflow_exit EXIT')
rewrite(rqlst, {('EXIT', 'X'): (snippet,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
"Any EXIT WHERE C? subworkflow_exit EXIT, EXIT is SubWorkflowExitPoint, "
"EXISTS(A subworkflow_exit EXIT, A name 'hop', A is WorkflowTransition), "
"C is WorkflowTransition")
@@ -313,7 +313,7 @@
trinfo_constraint = ('X wf_info_for Y, Y require_permission P, P name "read"')
rqlst = parse('Any U,T WHERE U is CWUser, T wf_info_for U')
rewrite(rqlst, {('T', 'X'): (trinfo_constraint, 'X wf_info_for Y, Y in_group G, G name "managers"')}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any U,T WHERE U is CWUser, T wf_info_for U, "
"EXISTS(U in_group B, B name 'managers', B is CWGroup), T is TrInfo")
@@ -322,14 +322,14 @@
trinfo_constraint = ('X wf_info_for Y, Y require_permission P, P name "read"')
rqlst = parse('Any T WHERE T wf_info_for X')
rewrite(rqlst, {('T', 'X'): (trinfo_constraint, 'X in_group G, G name "managers"')}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u'XXX dunno what should be generated')
def test_add_ambiguity_exists(self):
constraint = ('X concerne Y')
rqlst = parse('Affaire X')
rewrite(rqlst, {('X', 'X'): (constraint,)}, {})
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any X WHERE X is Affaire, ((EXISTS(X concerne A, A is Division)) OR (EXISTS(X concerne C, C is Societe))) OR (EXISTS(X concerne B, B is Note))")
def test_add_ambiguity_outerjoin(self):
@@ -337,7 +337,7 @@
rqlst = parse('Any X,C WHERE X? documented_by C')
rewrite(rqlst, {('X', 'X'): (constraint,)}, {})
# ambiguity are kept in the sub-query, no need to be resolved using OR
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any X,C WHERE X? documented_by C, C is Card WITH X BEING (Any X WHERE EXISTS(X concerne A), X is Affaire)")
@@ -345,76 +345,76 @@
constraint = RRQLExpression('S owned_by U')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)")
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any C WHERE C is Card")
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SOU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)")
def test_rrqlexpr_nonexistant_subject_2(self):
constraint = RRQLExpression('S owned_by U, O owned_by U, O is Card')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
'Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A)')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
'Any C WHERE C is Card, B eid %(D)s, EXISTS(A owned_by B, A is Card)')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SOU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
'Any C WHERE C is Card, A eid %(B)s, EXISTS(C owned_by A, D owned_by A, D is Card)')
def test_rrqlexpr_nonexistant_subject_3(self):
constraint = RRQLExpression('U in_group G, G name "users"')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", D is CWGroup)')
def test_rrqlexpr_nonexistant_subject_4(self):
constraint = RRQLExpression('U in_group G, G name "users", S owned_by U')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'SU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", C owned_by A, D is CWGroup)')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'OU')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u'Any C WHERE C is Card, A eid %(B)s, EXISTS(A in_group D, D name "users", D is CWGroup)')
def test_rrqlexpr_nonexistant_subject_5(self):
constraint = RRQLExpression('S owned_by Z, O owned_by Z, O is Card')
rqlst = parse('Card C')
rewrite(rqlst, {('C', 'S'): (constraint,)}, {}, 'S')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u"Any C WHERE C is Card, EXISTS(C owned_by A, A is CWUser)")
def test_rqlexpr_not_relation_1_1(self):
constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
rqlst = parse('Affaire A WHERE NOT EXISTS(A documented_by C)')
rewrite(rqlst, {('C', 'X'): (constraint,)}, {}, 'X')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire')
def test_rqlexpr_not_relation_1_2(self):
constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
rqlst = parse('Affaire A WHERE NOT EXISTS(A documented_by C)')
rewrite(rqlst, {('A', 'X'): (constraint,)}, {}, 'X')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u'Any A WHERE NOT EXISTS(A documented_by C, C is Card), A is Affaire, EXISTS(A owned_by B, B login "hop", B is CWUser)')
def test_rqlexpr_not_relation_2(self):
constraint = RRQLExpression('X owned_by Z, Z login "hop"', 'X')
rqlst = rqlhelper.parse('Affaire A WHERE NOT A documented_by C', annotate=False)
rewrite(rqlst, {('C', 'X'): (constraint,)}, {}, 'X')
- self.failUnlessEqual(rqlst.as_string(),
+ self.assertEqual(rqlst.as_string(),
u'Any A WHERE NOT EXISTS(A documented_by C, EXISTS(C owned_by B, B login "hop", B is CWUser), C is Card), A is Affaire')
--- a/test/unittest_rset.py Wed Sep 14 09:10:58 2011 +0200
+++ b/test/unittest_rset.py Wed Sep 14 09:11:50 2011 +0200
@@ -401,7 +401,7 @@
def test_entities(self):
rset = self.execute('Any U,G WHERE U in_group G')
# make sure we have at least one element
- self.failUnless(rset)
+ self.assertTrue(rset)
self.assertEqual(set(e.e_schema.type for e in rset.entities(0)),
set(['CWUser',]))
self.assertEqual(set(e.e_schema.type for e in rset.entities(1)),
@@ -410,7 +410,7 @@
def test_iter_rows_with_entities(self):
rset = self.execute('Any U,UN,G,GN WHERE U in_group G, U login UN, G name GN')
# make sure we have at least one element
- self.failUnless(rset)
+ self.assertTrue(rset)
out = list(rset.iter_rows_with_entities())[0]
self.assertEqual( out[0].login, out[1] )
self.assertEqual( out[2].name, out[3] )
--- a/test/unittest_schema.py Wed Sep 14 09:10:58 2011 +0200
+++ b/test/unittest_schema.py Wed Sep 14 09:11:50 2011 +0200
@@ -106,9 +106,9 @@
# isinstance(cstr, RQLConstraint)
# -> expected to return RQLConstraint instances but not
# RRQLVocabularyConstraint and QLUniqueConstraint
- self.failIf(issubclass(RQLUniqueConstraint, RQLVocabularyConstraint))
- self.failIf(issubclass(RQLUniqueConstraint, RQLConstraint))
- self.failUnless(issubclass(RQLConstraint, RQLVocabularyConstraint))
+ self.assertFalse(issubclass(RQLUniqueConstraint, RQLVocabularyConstraint))
+ self.assertFalse(issubclass(RQLUniqueConstraint, RQLConstraint))
+ self.assertTrue(issubclass(RQLConstraint, RQLVocabularyConstraint))
def test_entity_perms(self):
self.assertEqual(eperson.get_groups('read'), set(('managers', 'users', 'guests')))
@@ -238,15 +238,15 @@
properties = rschema.rdef('CWAttribute', 'CWRType')
self.assertEqual(properties.cardinality, '1*')
constraints = properties.constraints
- self.failUnlessEqual(len(constraints), 1, constraints)
+ self.assertEqual(len(constraints), 1, constraints)
constraint = constraints[0]
- self.failUnless(isinstance(constraint, RQLConstraint))
- self.failUnlessEqual(constraint.expression, 'O final TRUE')
+ self.assertTrue(isinstance(constraint, RQLConstraint))
+ self.assertEqual(constraint.expression, 'O final TRUE')
def test_fulltext_container(self):
schema = loader.load(config)
- self.failUnless('has_text' in schema['CWUser'].subject_relations())
- self.failIf('has_text' in schema['EmailAddress'].subject_relations())
+ self.assertTrue('has_text' in schema['CWUser'].subject_relations())
+ self.assertFalse('has_text' in schema['EmailAddress'].subject_relations())
def test_permission_settings(self):
schema = loader.load(config)
--- a/test/unittest_selectors.py Wed Sep 14 09:10:58 2011 +0200
+++ b/test/unittest_selectors.py Wed Sep 14 09:11:50 2011 +0200
@@ -87,11 +87,11 @@
def test_composition(self):
selector = (_1_() & _1_()) & (_1_() & _1_())
- self.failUnless(isinstance(selector, AndSelector))
+ self.assertTrue(isinstance(selector, AndSelector))
self.assertEqual(len(selector.selectors), 4)
self.assertEqual(selector(None), 4)
selector = (_1_() & _0_()) | (_1_() & _1_())
- self.failUnless(isinstance(selector, OrSelector))
+ self.assertTrue(isinstance(selector, OrSelector))
self.assertEqual(len(selector.selectors), 2)
self.assertEqual(selector(None), 2)
@@ -151,13 +151,13 @@
rset = f.as_rset()
anyscore = is_instance('Any')(f.__class__, req, rset=rset)
idownscore = adaptable('IDownloadable')(f.__class__, req, rset=rset)
- self.failUnless(idownscore > anyscore, (idownscore, anyscore))
+ self.assertTrue(idownscore > anyscore, (idownscore, anyscore))
filescore = is_instance('File')(f.__class__, req, rset=rset)
- self.failUnless(filescore > idownscore, (filescore, idownscore))
+ self.assertTrue(filescore > idownscore, (filescore, idownscore))
def test_etype_inheritance_no_yams_inheritance(self):
cls = self.vreg['etypes'].etype_class('Personne')
- self.failIf(is_instance('Societe').score_class(cls, self.request()))
+ self.assertFalse(is_instance('Societe').score_class(cls, self.request()))
def test_yams_inheritance(self):
cls = self.vreg['etypes'].etype_class('Transition')
@@ -321,7 +321,7 @@
self.vreg._loadedmods[__name__] = {}
self.vreg.register(SomeAction)
SomeAction.__registered__(self.vreg['actions'])
- self.failUnless(SomeAction in self.vreg['actions']['yo'], self.vreg['actions'])
+ self.assertTrue(SomeAction in self.vreg['actions']['yo'], self.vreg['actions'])
try:
# login as a simple user
req = self.request()
@@ -330,18 +330,18 @@
# it should not be possible to use SomeAction not owned objects
req = self.request()
rset = req.execute('Any G WHERE G is CWGroup, G name "managers"')
- self.failIf('yo' in dict(self.pactions(req, rset)))
+ self.assertFalse('yo' in dict(self.pactions(req, rset)))
# insert a new card, and check that we can use SomeAction on our object
self.execute('INSERT Card C: C title "zoubidou"')
self.commit()
req = self.request()
rset = req.execute('Card C WHERE C title "zoubidou"')
- self.failUnless('yo' in dict(self.pactions(req, rset)), self.pactions(req, rset))
+ self.assertTrue('yo' in dict(self.pactions(req, rset)), self.pactions(req, rset))
# make sure even managers can't use the action
self.restore_connection()
req = self.request()
rset = req.execute('Card C WHERE C title "zoubidou"')
- self.failIf('yo' in dict(self.pactions(req, rset)))
+ self.assertFalse('yo' in dict(self.pactions(req, rset)))
finally:
del self.vreg[SomeAction.__registry__][SomeAction.__regid__]
--- a/test/unittest_utils.py Wed Sep 14 09:10:58 2011 +0200
+++ b/test/unittest_utils.py Wed Sep 14 09:11:50 2011 +0200
@@ -67,7 +67,7 @@
# XXX
self.assertEqual(l[4], (1, 3))
- self.failIf(RepeatList(0, None))
+ self.assertFalse(RepeatList(0, None))
def test_slice(self):
l = RepeatList(3, (1, 3))
--- a/test/unittest_vregistry.py Wed Sep 14 09:10:58 2011 +0200
+++ b/test/unittest_vregistry.py Wed Sep 14 09:11:50 2011 +0200
@@ -56,7 +56,7 @@
def test_load_subinterface_based_appobjects(self):
self.vreg.register_objects([join(BASE, 'web', 'views', 'iprogress.py')])
# check progressbar was kicked
- self.failIf(self.vreg['views'].get('progressbar'))
+ self.assertFalse(self.vreg['views'].get('progressbar'))
# we've to emulate register_objects to add custom MyCard objects
path = [join(BASE, 'entities', '__init__.py'),
join(BASE, 'entities', 'adapters.py'),
@@ -74,8 +74,8 @@
def test_properties(self):
self.vreg.reset()
- self.failIf('system.version.cubicweb' in self.vreg['propertydefs'])
- self.failUnless(self.vreg.property_info('system.version.cubicweb'))
+ self.assertFalse('system.version.cubicweb' in self.vreg['propertydefs'])
+ self.assertTrue(self.vreg.property_info('system.version.cubicweb'))
self.assertRaises(UnknownProperty, self.vreg.property_info, 'a.non.existent.key')
--- a/web/test/test_views.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/test_views.py Wed Sep 14 09:11:50 2011 +0200
@@ -52,10 +52,10 @@
def test_sortable_js_added(self):
rset = self.execute('CWUser X')
# sortable.js should not be included by default
- self.failIf('jquery.tablesorter.js' in self.view('oneline', rset))
+ self.assertFalse('jquery.tablesorter.js' in self.view('oneline', rset))
# but should be included by the tableview
rset = self.execute('Any P,F,S LIMIT 1 WHERE P is CWUser, P firstname F, P surname S')
- self.failUnless('jquery.tablesorter.js' in self.view('table', rset))
+ self.assertTrue('jquery.tablesorter.js' in self.view('table', rset))
def test_js_added_only_once(self):
self.vreg._loadedmods[__name__] = {}
--- a/web/test/unittest_application.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_application.py Wed Sep 14 09:11:50 2011 +0200
@@ -274,8 +274,8 @@
def _test_cleaned(self, kwargs, injected, cleaned):
req = self.request(**kwargs)
page = self.app.publish('view', req)
- self.failIf(injected in page, (kwargs, injected))
- self.failUnless(cleaned in page, (kwargs, cleaned))
+ self.assertFalse(injected in page, (kwargs, injected))
+ self.assertTrue(cleaned in page, (kwargs, cleaned))
def test_nonregr_script_kiddies(self):
"""test against current script injection"""
@@ -321,9 +321,9 @@
origcnx = req.cnx
req.form['__fblogin'] = u'turlututu'
page = self.app_publish(req)
- self.failIf(req.cnx is origcnx)
+ self.assertFalse(req.cnx is origcnx)
self.assertEqual(req.user.login, 'turlututu')
- self.failUnless('turlututu' in page, page)
+ self.assertTrue('turlututu' in page, page)
req.cnx.close() # avoid warning
# authentication tests ####################################################
@@ -343,8 +343,8 @@
req, origsession = self.init_authentication('cookie')
self.assertAuthFailure(req)
form = self.app_publish(req, 'login')
- self.failUnless('__login' in form)
- self.failUnless('__password' in form)
+ self.assertTrue('__login' in form)
+ self.assertTrue('__password' in form)
self.assertEqual(req.cnx, None)
req.form['__login'] = self.admlogin
req.form['__password'] = self.admpassword
@@ -389,7 +389,7 @@
asession = req.session
self.assertEqual(len(self.open_sessions), 1)
self.assertEqual(asession.login, 'anon')
- self.failUnless(asession.anonymous_session)
+ self.assertTrue(asession.anonymous_session)
self._reset_cookie(req)
def _test_anon_auth_fail(self, req):
--- a/web/test/unittest_form.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_form.py Wed Sep 14 09:11:50 2011 +0200
@@ -64,15 +64,15 @@
t = self.req.create_entity('Tag', name=u'x')
form1 = self.vreg['forms'].select('edition', self.req, entity=t)
unrelated = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)]
- self.failUnless(unicode(b.eid) in unrelated, unrelated)
+ self.assertTrue(unicode(b.eid) in unrelated, unrelated)
form2 = self.vreg['forms'].select('edition', self.req, entity=b)
unrelated = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)]
- self.failUnless(unicode(t.eid) in unrelated, unrelated)
+ self.assertTrue(unicode(t.eid) in unrelated, unrelated)
self.execute('SET X tags Y WHERE X is Tag, Y is BlogEntry')
unrelated = [reid for rview, reid in form1.field_by_name('tags', 'subject', t.e_schema).choices(form1)]
- self.failIf(unicode(b.eid) in unrelated, unrelated)
+ self.assertFalse(unicode(b.eid) in unrelated, unrelated)
unrelated = [reid for rview, reid in form2.field_by_name('tags', 'object', t.e_schema).choices(form2)]
- self.failIf(unicode(t.eid) in unrelated, unrelated)
+ self.assertFalse(unicode(t.eid) in unrelated, unrelated)
def test_form_field_vocabulary_new_entity(self):
@@ -110,14 +110,14 @@
ok = True
self.assertEqual(ok, True, 'expected option not found')
inputs = pageinfo.find_tag('input', False)
- self.failIf(list(pageinfo.matching_nodes('input', name='__linkto')))
+ self.assertFalse(list(pageinfo.matching_nodes('input', name='__linkto')))
def test_reledit_composite_field(self):
rset = self.execute('INSERT BlogEntry X: X title "cubicweb.org", X content "hop"')
form = self.vreg['views'].select('reledit', self.request(),
rset=rset, row=0, rtype='content')
data = form.render(row=0, rtype='content', formid='base', action='edit_rtype')
- self.failUnless('content_format' in data)
+ self.assertTrue('content_format' in data)
# form view tests #########################################################
--- a/web/test/unittest_propertysheet.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_propertysheet.py Wed Sep 14 09:11:50 2011 +0200
@@ -35,19 +35,19 @@
'a {bgcolor: #FFFFFF; size: 1%;}')
self.assertEqual(ps.process_resource(DATADIR, 'pouet.css'),
CACHEDIR)
- self.failUnless('pouet.css' in ps._cache)
- self.failIf(ps.need_reload())
+ self.assertTrue('pouet.css' in ps._cache)
+ self.assertFalse(ps.need_reload())
os.utime(join(DATADIR, 'sheet1.py'), None)
- self.failUnless('pouet.css' in ps._cache)
- self.failUnless(ps.need_reload())
- self.failUnless('pouet.css' in ps._cache)
+ self.assertTrue('pouet.css' in ps._cache)
+ self.assertTrue(ps.need_reload())
+ self.assertTrue('pouet.css' in ps._cache)
ps.reload()
- self.failIf('pouet.css' in ps._cache)
- self.failIf(ps.need_reload())
+ self.assertFalse('pouet.css' in ps._cache)
+ self.assertFalse(ps.need_reload())
ps.process_resource(DATADIR, 'pouet.css') # put in cache
os.utime(join(DATADIR, 'pouet.css'), None)
- self.failIf(ps.need_reload())
- self.failIf('pouet.css' in ps._cache)
+ self.assertFalse(ps.need_reload())
+ self.assertFalse('pouet.css' in ps._cache)
if __name__ == '__main__':
unittest_main()
--- a/web/test/unittest_uicfg.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_uicfg.py Wed Sep 14 09:11:50 2011 +0200
@@ -24,7 +24,7 @@
class UICFGTC(CubicWebTC):
def test_default_actionbox_appearsin_addmenu_config(self):
- self.failIf(abaa.etype_get('TrInfo', 'wf_info_for', 'object', 'CWUser'))
+ self.assertFalse(abaa.etype_get('TrInfo', 'wf_info_for', 'object', 'CWUser'))
--- a/web/test/unittest_views_actions.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_views_actions.py Wed Sep 14 09:11:50 2011 +0200
@@ -34,12 +34,12 @@
req = self.request()
rset = self.execute('Any X WHERE X login "admin"', req=req)
actions = self.vreg['actions'].poss_visible_objects(req, rset=rset)
- self.failUnless([action for action in actions if action.__regid__ == 'sendemail'])
+ self.assertTrue([action for action in actions if action.__regid__ == 'sendemail'])
self.login('anon')
req = self.request()
rset = self.execute('Any X WHERE X login "anon"', req=req)
actions = self.vreg['actions'].poss_visible_objects(req, rset=rset)
- self.failIf([action for action in actions if action.__regid__ == 'sendemail'])
+ self.assertFalse([action for action in actions if action.__regid__ == 'sendemail'])
if __name__ == '__main__':
unittest_main()
--- a/web/test/unittest_views_basecontrollers.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_views_basecontrollers.py Wed Sep 14 09:11:50 2011 +0200
@@ -40,11 +40,11 @@
class EditControllerTC(CubicWebTC):
def setUp(self):
CubicWebTC.setUp(self)
- self.failUnless('users' in self.schema.eschema('CWGroup').get_groups('read'))
+ self.assertTrue('users' in self.schema.eschema('CWGroup').get_groups('read'))
def tearDown(self):
CubicWebTC.tearDown(self)
- self.failUnless('users' in self.schema.eschema('CWGroup').get_groups('read'))
+ self.assertTrue('users' in self.schema.eschema('CWGroup').get_groups('read'))
def test_noparam_edit(self):
"""check behaviour of this controller without any form parameter
@@ -107,7 +107,7 @@
path, params = self.expect_redirect_publish(req, 'edit')
cnx.commit() # commit to check we don't get late validation error for instance
self.assertEqual(path, 'cwuser/user')
- self.failIf('vid' in params)
+ self.assertFalse('vid' in params)
def test_user_editing_itself_no_relation(self):
"""checking we can edit an entity without specifying some required
@@ -308,7 +308,7 @@
'__action_apply': '',
}
path, params = self.expect_redirect_publish(req, 'edit')
- self.failUnless(path.startswith('blogentry/'))
+ self.assertTrue(path.startswith('blogentry/'))
eid = path.split('/')[1]
self.assertEqual(params['vid'], 'edition')
self.assertNotEqual(int(eid), 4012)
@@ -442,7 +442,7 @@
'title-subject:A': u'"13:03:40"',
'content-subject:A': u'"13:03:43"',}
path, params = self.expect_redirect_publish(req, 'edit')
- self.failUnless(path.startswith('blogentry/'))
+ self.assertTrue(path.startswith('blogentry/'))
eid = path.split('/')[1]
e = self.execute('Any C, T WHERE C eid %(x)s, C content T', {'x': eid}).get_entity(0, 0)
self.assertEqual(e.title, '"13:03:40"')
@@ -578,12 +578,12 @@
rset = self.john.as_rset()
rset.req = req
source = ctrl.publish()
- self.failUnless(source.startswith('<?xml version="1.0"?>\n' + STRICT_DOCTYPE +
+ self.assertTrue(source.startswith('<?xml version="1.0"?>\n' + STRICT_DOCTYPE +
u'<div xmlns="http://www.w3.org/1999/xhtml" xmlns:cubicweb="http://www.logilab.org/2008/cubicweb">')
)
req.xhtml_browser = lambda: False
source = ctrl.publish()
- self.failUnless(source.startswith('<div>'))
+ self.assertTrue(source.startswith('<div>'))
# def test_json_exec(self):
# rql = 'Any T,N WHERE T is Tag, T name N'
--- a/web/test/unittest_views_editforms.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_views_editforms.py Wed Sep 14 09:11:50 2011 +0200
@@ -95,9 +95,9 @@
]))
def test_inlined_view(self):
- self.failUnless('main_inlined' in AFS.etype_get('CWUser', 'use_email', 'subject', 'EmailAddress'))
- self.failIf('main_inlined' in AFS.etype_get('CWUser', 'primary_email', 'subject', 'EmailAddress'))
- self.failUnless('main_relations' in AFS.etype_get('CWUser', 'primary_email', 'subject', 'EmailAddress'))
+ self.assertTrue('main_inlined' in AFS.etype_get('CWUser', 'use_email', 'subject', 'EmailAddress'))
+ self.assertFalse('main_inlined' in AFS.etype_get('CWUser', 'primary_email', 'subject', 'EmailAddress'))
+ self.assertTrue('main_relations' in AFS.etype_get('CWUser', 'primary_email', 'subject', 'EmailAddress'))
def test_personne_relations_by_category(self):
e = self.vreg['etypes'].etype_class('Personne')(self.request())
@@ -142,7 +142,7 @@
# should be also selectable by specifying entity
self.vreg['forms'].select('edition', rset.req,
entity=rset.get_entity(0, 0))
- self.failIf(any(f for f in form.fields if f is None))
+ self.assertFalse(any(f for f in form.fields if f is None))
class FormViewsTC(CubicWebTC):
--- a/web/test/unittest_views_navigation.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_views_navigation.py Wed Sep 14 09:11:50 2011 +0200
@@ -126,12 +126,12 @@
# req, rset=rset, view=view, context='navtop')
# # breadcrumbs should be in headers by default
# clsids = set(obj.id for obj in objs)
- # self.failUnless('breadcrumbs' in clsids)
+ # self.assertTrue('breadcrumbs' in clsids)
# objs = self.vreg['ctxcomponents'].poss_visible_objects(
# req, rset=rset, view=view, context='navbottom')
# # breadcrumbs should _NOT_ be in footers by default
# clsids = set(obj.id for obj in objs)
- # self.failIf('breadcrumbs' in clsids)
+ # self.assertFalse('breadcrumbs' in clsids)
# self.execute('INSERT CWProperty P: P pkey "ctxcomponents.breadcrumbs.context", '
# 'P value "navbottom"')
# # breadcrumbs should now be in footers
@@ -140,12 +140,12 @@
# req, rset=rset, view=view, context='navbottom')
# clsids = [obj.id for obj in objs]
- # self.failUnless('breadcrumbs' in clsids)
+ # self.assertTrue('breadcrumbs' in clsids)
# objs = self.vreg['ctxcomponents'].poss_visible_objects(
# req, rset=rset, view=view, context='navtop')
# clsids = [obj.id for obj in objs]
- # self.failIf('breadcrumbs' in clsids)
+ # self.assertFalse('breadcrumbs' in clsids)
if __name__ == '__main__':
--- a/web/test/unittest_viewselector.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_viewselector.py Wed Sep 14 09:11:50 2011 +0200
@@ -165,9 +165,9 @@
req2 = self.request()
rset1 = req1.execute('CWUser X WHERE X login "admin"')
rset2 = req2.execute('CWUser X WHERE X login "anon"')
- self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=None))
- self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=rset1))
- self.failUnless(self.vreg['views'].select('propertiesform', req2, rset=rset2))
+ self.assertTrue(self.vreg['views'].select('propertiesform', req1, rset=None))
+ self.assertTrue(self.vreg['views'].select('propertiesform', req1, rset=rset1))
+ self.assertTrue(self.vreg['views'].select('propertiesform', req2, rset=rset2))
def test_propertiesform_anon(self):
self.login('anon')
@@ -186,9 +186,9 @@
req2 = self.request()
rset1 = req1.execute('CWUser X WHERE X login "admin"')
rset2 = req2.execute('CWUser X WHERE X login "jdoe"')
- self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=None))
+ self.assertTrue(self.vreg['views'].select('propertiesform', req1, rset=None))
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=rset1)
- self.failUnless(self.vreg['views'].select('propertiesform', req2, rset=rset2))
+ self.assertTrue(self.vreg['views'].select('propertiesform', req2, rset=rset2))
def test_possible_views_multiple_different_types(self):
req = self.request()
@@ -344,21 +344,21 @@
req = self.request()
self.assertIsInstance(self.vreg['views'].select('index', req, rset=rset),
startup.IndexView)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'primary', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'table', req, rset=rset)
# no entity
req = self.request()
rset = req.execute('Any X WHERE X eid 999999')
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'index', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'creation', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'primary', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'table', req, rset=rset)
# one entity
req = self.request()
@@ -371,9 +371,9 @@
editforms.EditionFormView)
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
tableview.TableView)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'creation', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'index', req, rset=rset)
# list of entities of the same type
req = self.request()
@@ -384,7 +384,7 @@
baseviews.ListView)
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
tableview.TableView)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'creation', req, rset=rset)
# list of entities of different types
req = self.request()
@@ -395,31 +395,31 @@
baseviews.ListView)
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
tableview.TableView)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'creation', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'index', req, rset=rset)
# whatever
req = self.request()
rset = req.execute('Any N, X WHERE X in_group Y, Y name N')
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
tableview.TableView)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'index', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'creation', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'primary', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'list', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'edition', req, rset=rset)
# mixed query
req = self.request()
rset = req.execute('Any U,G WHERE U is CWUser, G is CWGroup')
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'edition', req, rset=rset)
- self.failUnlessRaises(NoSelectableObject,
+ self.assertTrueRaises(NoSelectableObject,
self.vreg['views'].select, 'creation', req, rset=rset)
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
tableview.TableView)
--- a/web/test/unittest_web.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_web.py Wed Sep 14 09:11:50 2011 +0200
@@ -34,8 +34,8 @@
arurl = req.ajax_replace_url
# NOTE: for the simplest use cases, we could use doctest
url = arurl('foo', **kwargs)
- self.failUnless(url.startswith('javascript:'))
- self.failUnless(url.endswith('()'))
+ self.assertTrue(url.startswith('javascript:'))
+ self.assertTrue(url.endswith('()'))
cbname = url.split()[1][:-2]
self.assertMultiLineEqual(
'function %s() { $("#foo").loadxhtml("http://testing.fr/cubicweb/json?%s",{"pageid": "%s"},"get","replace"); }' % (cbname, qs, req.pageid),
--- a/web/test/unittest_webconfig.py Wed Sep 14 09:10:58 2011 +0200
+++ b/web/test/unittest_webconfig.py Wed Sep 14 09:11:50 2011 +0200
@@ -34,16 +34,16 @@
"""make sure PRINT_CSS *must* is a list"""
config = self.config
print_css = config.uiprops['STYLESHEETS_PRINT']
- self.failUnless(isinstance(print_css, list))
+ self.assertTrue(isinstance(print_css, list))
ie_css = config.uiprops['STYLESHEETS_IE']
- self.failUnless(isinstance(ie_css, list))
+ self.assertTrue(isinstance(ie_css, list))
def test_locate_resource(self):
- self.failUnless('FILE_ICON' in self.config.uiprops)
+ self.assertTrue('FILE_ICON' in self.config.uiprops)
rname = self.config.uiprops['FILE_ICON'].replace(self.config.datadir_url, '')
- self.failUnless('file' in self.config.locate_resource(rname)[0].split(os.sep))
+ self.assertTrue('file' in self.config.locate_resource(rname)[0].split(os.sep))
cubicwebcsspath = self.config.locate_resource('cubicweb.css')[0].split(os.sep)
- self.failUnless('web' in cubicwebcsspath or 'shared' in cubicwebcsspath) # 'shared' if tests under apycot
+ self.assertTrue('web' in cubicwebcsspath or 'shared' in cubicwebcsspath) # 'shared' if tests under apycot
if __name__ == '__main__':
unittest_main()