[schema hook] don't depends on lgc.testlib, hence unittest2 for a dumb mock stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 06 Jan 2011 18:53:00 +0100
branchstable
changeset 6789 f38963f7c91d
parent 6788 0f31ed3fff79
child 6790 f4f67ea5436a
[schema hook] don't depends on lgc.testlib, hence unittest2 for a dumb mock
hooks/syncschema.py
--- a/hooks/syncschema.py	Thu Jan 06 17:49:19 2011 +0100
+++ b/hooks/syncschema.py	Thu Jan 06 18:53:00 2011 +0100
@@ -30,7 +30,6 @@
 from yams import buildobjs as ybo, schema2sql as y2sql
 
 from logilab.common.decorators import clear_cache
-from logilab.common.testlib import mock_object
 
 from cubicweb import ValidationError
 from cubicweb.selectors import is_instance
@@ -131,6 +130,11 @@
         raise ValidationError(entity.eid, errors)
 
 
+class _MockEntity(object): # XXX use a named tuple with python 2.6
+    def __init__(self, eid):
+        self.eid = eid
+
+
 class SyncSchemaHook(hook.Hook):
     """abstract class for schema synchronization hooks (in the `syncschema`
     category)
@@ -266,8 +270,8 @@
             sampletype = rschema.subjects()[0]
             desttype = rschema.objects()[0]
             rdef = copy(rschema.rdef(sampletype, desttype))
-            rdef.subject = mock_object(eid=entity.eid)
-            mock = mock_object(eid=None)
+            rdef.subject = _MockEntity(eid=entity.eid)
+            mock = _MockEntity(eid=None)
             ss.execschemarql(session.execute, mock, ss.rdef2rql(rdef, cmap, gmap))
 
     def revertprecommit_event(self):