# HG changeset patch # User Sylvain Thénault # Date 1294336380 -3600 # Node ID f38963f7c91d2a52cd0fc3336bd0e78d80f4d06d # Parent 0f31ed3fff798c07e954fd18042f6339d04af564 [schema hook] don't depends on lgc.testlib, hence unittest2 for a dumb mock diff -r 0f31ed3fff79 -r f38963f7c91d 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):