server/test/unittest_multisources.py
changeset 6724 24bf6f181d0e
parent 6631 26c303c3f1aa
child 6762 812445504835
--- a/server/test/unittest_multisources.py	Wed Dec 01 17:09:19 2010 +0100
+++ b/server/test/unittest_multisources.py	Wed Dec 01 17:11:35 2010 +0100
@@ -1,4 +1,4 @@
- # copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of CubicWeb.
@@ -35,7 +35,6 @@
 pyro-ns-id = extern
 cubicweb-user = admin
 cubicweb-password = gingkow
-mapping-file = extern_mapping.py
 base-url=http://extern.org/
 '''
 
@@ -46,14 +45,25 @@
 PyroRQLSource_get_connection = PyroRQLSource.get_connection
 Connection_close = Connection.close
 
+def add_extern_mapping(source):
+    execute = source._cw.execute
+    for etype in ('Card', 'Affaire', 'State'):
+        assert execute('SET S cw_support ET WHERE ET name %(etype)s, ET is CWEType, S eid %(s)s',
+                       {'etype': etype, 's': source.eid})
+    for rtype in ('in_state', 'documented_by', 'multisource_inlined_rel'):
+        assert execute('SET S cw_support RT WHERE RT name %(rtype)s, RT is CWRType, S eid %(s)s',
+                       {'rtype': rtype, 's': source.eid})
+
+
 def setup_module(*args):
     global repo2, cnx2, repo3, cnx3
     cfg1 = ExternalSource1Configuration('data', apphome=TwoSourcesTC.datadir)
     repo2, cnx2 = init_test_database(config=cfg1)
     cfg2 = ExternalSource2Configuration('data', apphome=TwoSourcesTC.datadir)
     repo3, cnx3 = init_test_database(config=cfg2)
-    cnx3.request().create_entity('CWSource', name=u'extern', type=u'pyrorql',
-                                 config=EXTERN_SOURCE_CFG)
+    src = cnx3.request().create_entity('CWSource', name=u'extern',
+                                       type=u'pyrorql', config=EXTERN_SOURCE_CFG)
+    add_extern_mapping(src)
     cnx3.commit()
 
     TestServerConfiguration.no_sqlite_wrap = True
@@ -106,11 +116,11 @@
 pyro-ns-id = extern-multi
 cubicweb-user = admin
 cubicweb-password = gingkow
-mapping-file = extern_mapping.py
 ''')]:
-            self.request().create_entity('CWSource', name=unicode(uri),
-                                         type=u'pyrorql',
-                                         config=unicode(config))
+            source = self.request().create_entity(
+                'CWSource', name=unicode(uri), type=u'pyrorql',
+                config=unicode(config))
+            add_extern_mapping(source)
         self.commit()
         # trigger discovery
         self.sexecute('Card X')