Commit 807d5987 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[deprecation] fix unittest pending deprecation warnings on failIf/failUnless methods family

parent 7e16e056eecb
......@@ -72,7 +72,7 @@ class ValueGeneratorTC(TestCase):
"""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 @@ class ValueGeneratorTC(TestCase):
# 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"""
......
......@@ -41,31 +41,31 @@ class AutoExtendableTC(TestCase):
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__':
......
......@@ -88,10 +88,10 @@ class CWUserTC(BaseEntityTC):
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 @@ class InterfaceTC(CubicWebTC):
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 @@ class SpecializedEntityClassesTC(CubicWebTC):
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 @@ class SpecializedEntityClassesTC(CubicWebTC):
__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:
......
......@@ -567,7 +567,7 @@ class WorkflowHooksTC(CubicWebTC):
# 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]
......
......@@ -69,7 +69,7 @@ class ConcatFilesTC(CubicWebTC):
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
......
......@@ -28,10 +28,10 @@ class BookmarkHooksTC(CubicWebTC):
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()
......@@ -117,7 +117,7 @@ class UserGroupHooksTC(CubicWebTC):
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 @@ class UserGroupHooksTC(CubicWebTC):
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}))
......
......@@ -62,7 +62,7 @@ class CoreHooksTC(CubicWebTC):
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')
......
......@@ -60,18 +60,18 @@ class SchemaModificationHooksTC(CubicWebTC):
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 @@ class SchemaModificationHooksTC(CubicWebTC):
'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 @@ class SchemaModificationHooksTC(CubicWebTC):
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 @@ class SchemaModificationHooksTC(CubicWebTC):
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 @@ class SchemaModificationHooksTC(CubicWebTC):
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 @@ class SchemaModificationHooksTC(CubicWebTC):
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 @@ class SchemaModificationHooksTC(CubicWebTC):
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 @@ class SchemaModificationHooksTC(CubicWebTC):
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 @@ class SchemaModificationHooksTC(CubicWebTC):
{'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 @@ class SchemaModificationHooksTC(CubicWebTC):
'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"')
......
......@@ -46,9 +46,9 @@ class CheckIntegrityTC(TestCase):
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 @@ class CheckIntegrityTC(TestCase):
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()
......@@ -115,8 +115,8 @@ class DataFeedTC(CubicWebTC):
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
......
......@@ -262,7 +262,7 @@ class LDAPUserSourceTC(CubicWebTC):
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 @@ class LDAPUserSourceTC(CubicWebTC):
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 @@ class LDAPUserSourceTC(CubicWebTC):
'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})
......
......@@ -74,13 +74,13 @@ class MigrationCommandsTC(CubicWebTC):
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 @@ class MigrationCommandsTC(CubicWebTC):
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 @@ class MigrationCommandsTC(CubicWebTC):
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 @@ class MigrationCommandsTC(CubicWebTC):
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 @@ class MigrationCommandsTC(CubicWebTC):
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 @@ class MigrationCommandsTC(CubicWebTC):
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 @@ class MigrationCommandsTC(CubicWebTC):
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()),