[test] during some tests (unittest_migrations), we should not register ClearGroupMap which is actually already there stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 10 Sep 2010 14:32:38 +0200
branchstable
changeset 6203 d3dea5f84404
parent 6202 30f6e9d2addc
child 6204 fd6d8f4d1904
[test] during some tests (unittest_migrations), we should not register ClearGroupMap which is actually already there
server/migractions.py
--- a/server/migractions.py	Fri Sep 10 14:31:42 2010 +0200
+++ b/server/migractions.py	Fri Sep 10 14:32:38 2010 +0200
@@ -93,16 +93,19 @@
             self.repo_connect()
         # no config on shell to a remote instance
         if config is not None and (cnx or connect):
+            repo = self.repo
             self.session.data['rebuild-infered'] = False
             # register a hook to clear our group_mapping cache and the
             # self._synchronized set when some group is added or updated
             ClearGroupMap.mih = self
-            self.repo.vreg.register(ClearGroupMap)
-            CW_EVENT_MANAGER.bind('after-registry-reload',
-                                  self.repo.vreg.register, ClearGroupMap)
+            # may be already registered in tests (e.g. unittest_migractions)
+            if not ClearGroupMap.__regid__ in repo.vreg['after_add_entity_hooks']:
+                repo.vreg.register(ClearGroupMap)
+                CW_EVENT_MANAGER.bind('after-registry-reload',
+                                      repo.vreg.register, ClearGroupMap)
             # notify we're starting maintenance (called instead of server_start
             # which is called on regular start
-            self.repo.hm.call_hooks('server_maintenance', repo=self.repo)
+            repo.hm.call_hooks('server_maintenance', repo=repo)
         if not schema and not getattr(config, 'quick_start', False):
             schema = config.load_schema(expand_cubes=True)
         self.fs_schema = schema