diff -r ec9c20c6b9f7 -r 162b2b127b15 server/test/unittest_repository.py --- a/server/test/unittest_repository.py Wed Mar 03 17:59:05 2010 +0100 +++ b/server/test/unittest_repository.py Wed Mar 03 18:30:25 2010 +0100 @@ -21,7 +21,7 @@ from cubicweb import (BadConnectionId, RepositoryError, ValidationError, UnknownEid, AuthenticationError) from cubicweb.schema import CubicWebSchema, RQLConstraint -from cubicweb.dbapi import connect, repo_connect, multiple_connections_unfix +from cubicweb.dbapi import connect, multiple_connections_unfix from cubicweb.devtools.testlib import CubicWebTC from cubicweb.devtools.repotest import tuplify from cubicweb.server import repository, hook @@ -38,25 +38,29 @@ """ def test_fill_schema(self): - self.repo.schema = CubicWebSchema(self.repo.config.appid) - self.repo.config._cubes = None # avoid assertion error - self.repo.config.repairing = True # avoid versions checking - self.repo.fill_schema() - table = SQL_PREFIX + 'CWEType' - namecol = SQL_PREFIX + 'name' - finalcol = SQL_PREFIX + 'final' - self.session.set_pool() - cu = self.session.system_sql('SELECT %s FROM %s WHERE %s is NULL' % ( - namecol, table, finalcol)) - self.assertEquals(cu.fetchall(), []) - cu = self.session.system_sql('SELECT %s FROM %s WHERE %s=%%(final)s ORDER BY %s' - % (namecol, table, finalcol, namecol), {'final': 'TRUE'}) - self.assertEquals(cu.fetchall(), [(u'Boolean',), (u'Bytes',), - (u'Date',), (u'Datetime',), - (u'Decimal',),(u'Float',), - (u'Int',), - (u'Interval',), (u'Password',), - (u'String',), (u'Time',)]) + origshema = self.repo.schema + try: + self.repo.schema = CubicWebSchema(self.repo.config.appid) + self.repo.config._cubes = None # avoid assertion error + self.repo.config.repairing = True # avoid versions checking + self.repo.fill_schema() + table = SQL_PREFIX + 'CWEType' + namecol = SQL_PREFIX + 'name' + finalcol = SQL_PREFIX + 'final' + self.session.set_pool() + cu = self.session.system_sql('SELECT %s FROM %s WHERE %s is NULL' % ( + namecol, table, finalcol)) + self.assertEquals(cu.fetchall(), []) + cu = self.session.system_sql('SELECT %s FROM %s WHERE %s=%%(final)s ORDER BY %s' + % (namecol, table, finalcol, namecol), {'final': 'TRUE'}) + self.assertEquals(cu.fetchall(), [(u'Boolean',), (u'Bytes',), + (u'Date',), (u'Datetime',), + (u'Decimal',),(u'Float',), + (u'Int',), + (u'Interval',), (u'Password',), + (u'String',), (u'Time',)]) + finally: + self.repo.set_schema(origshema) def test_schema_has_owner(self): repo = self.repo @@ -263,6 +267,8 @@ self.fail('something went wrong, thread still alive') finally: repository.pyro_unregister(self.repo.config) + from logilab.common import pyro_ext + pyro_ext._DAEMONS.clear() def _pyro_client(self, done): cnx = connect(self.repo.config.appid, u'admin', password='gingkow') @@ -456,13 +462,6 @@ u'system.version.tag']) CALLED = [] -class EcritParHook(hook.Hook): - __regid__ = 'inlinedrelhook' - __select__ = hook.Hook.__select__ & hook.match_rtype('ecrit_par') - events = ('before_add_relation', 'after_add_relation', - 'before_delete_relation', 'after_delete_relation') - def __call__(self): - CALLED.append((self.event, self.eidfrom, self.rtype, self.eidto)) class InlineRelHooksTC(CubicWebTC): """test relation hooks are called for inlined relations @@ -477,6 +476,14 @@ def test_inline_relation(self): """make sure _relation hooks are called for inlined relation""" + class EcritParHook(hook.Hook): + __regid__ = 'inlinedrelhook' + __select__ = hook.Hook.__select__ & hook.match_rtype('ecrit_par') + events = ('before_add_relation', 'after_add_relation', + 'before_delete_relation', 'after_delete_relation') + def __call__(self): + CALLED.append((self.event, self.eidfrom, self.rtype, self.eidto)) + self.hm.register(EcritParHook) eidp = self.execute('INSERT Personne X: X nom "toto"')[0][0] eidn = self.execute('INSERT Note X: X type "T"')[0][0]