--- a/entities/test/unittest_base.py Mon Sep 14 12:28:22 2009 +0200
+++ b/entities/test/unittest_base.py Mon Sep 14 12:48:25 2009 +0200
@@ -16,7 +16,6 @@
from cubicweb import ValidationError
from cubicweb.interfaces import IMileStone, IWorkflowable
from cubicweb.entities import AnyEntity
-from cubicweb.entities.authobjs import CWUser
from cubicweb.web.widgets import AutoCompletionWidget
@@ -64,9 +63,9 @@
email2 = self.execute('INSERT EmailAddress X: X address "maarten@philips.com"').get_entity(0, 0)
email3 = self.execute('INSERT EmailAddress X: X address "toto@logilab.fr"').get_entity(0, 0)
self.execute('SET X prefered_form Y WHERE X eid %s, Y eid %s' % (email1.eid, email2.eid))
- self.assertEquals(email1.canonical_form().eid, email2.eid)
- self.assertEquals(email2.canonical_form(), email2.eid)
- self.assertEquals(email3.canonical_form(), email3.eid)
+ self.assertEquals(email1.prefered.eid, email2.eid)
+ self.assertEquals(email2.prefered.eid, email2.eid)
+ self.assertEquals(email3.prefered.eid, email3.eid)
def test_mangling(self):
eid = self.execute('INSERT EmailAddress X: X address "maarten.ter.huurne@philips.com"')[0][0]
@@ -99,6 +98,7 @@
class InterfaceTC(EnvBasedTC):
def test_nonregr_subclasses_and_mixins_interfaces(self):
+ CWUser = self.vreg['etypes'].etype_class('CWUser')
self.failUnless(implements(CWUser, IWorkflowable))
class MyUser(CWUser):
__implements__ = (IMileStone,)
@@ -106,9 +106,13 @@
self.vreg.register_appobject_class(MyUser)
self.vreg['etypes'].initialization_completed()
MyUser_ = self.vreg['etypes'].etype_class('CWUser')
- self.failUnless(MyUser is MyUser_)
+ # a copy is done systematically
+ self.failUnless(issubclass(MyUser_, MyUser))
self.failUnless(implements(MyUser_, IMileStone))
self.failUnless(implements(MyUser_, IWorkflowable))
+ # original class should not have beed modified, only the copy
+ self.failUnless(implements(MyUser, IMileStone))
+ self.failIf(implements(MyUser, IWorkflowable))
class SpecializedEntityClassesTC(EnvBasedTC):
@@ -131,11 +135,11 @@
id = etype
self.vreg.register_appobject_class(Foo)
eclass = self.select_eclass('SubDivision')
+ self.failUnless(eclass.__autogenerated__)
if etype == 'SubDivision':
- self.failUnless(eclass is Foo)
+ self.assertEquals(eclass.__bases__, (Foo,))
else:
- self.failUnless(eclass.__autogenerated__)
- self.assertEquals(eclass.__bases__, (Foo,))
+ self.assertEquals(eclass.__bases__[0].__bases__, (Foo,))
# check Division eclass is still selected for plain Division entities
eclass = self.select_eclass('Division')
self.assertEquals(eclass.id, 'Division')
--- a/entities/test/unittest_wfobjs.py Mon Sep 14 12:28:22 2009 +0200
+++ b/entities/test/unittest_wfobjs.py Mon Sep 14 12:48:25 2009 +0200
@@ -335,12 +335,12 @@
self.assertEquals(self.member.state, 'asleep')# no change before commit
self.commit()
self.member.clear_all_caches()
- self.assertEquals(self.member.current_workflow.name, "CWUser workflow")
+ self.assertEquals(self.member.current_workflow.name, "default user workflow")
self.assertEquals(self.member.state, 'activated')
self.assertEquals(parse_hist(self.member.workflow_history),
[('activated', 'deactivated', 'deactivate', None),
('deactivated', 'asleep', None, 'workflow changed to "CWUser"'),
- ('asleep', 'activated', None, 'workflow changed to "CWUser workflow"'),])
+ ('asleep', 'activated', None, 'workflow changed to "default user workflow"'),])
from cubicweb.devtools.apptest import RepositoryBasedTC