[test] add config file in tests following narval changes to use instance_id
authorDavid Douard <david.douard@logilab.fr>
Tue, 22 Oct 2013 21:47:29 +0200
changeset 1452 ab2a19b30283
parent 1451 fed7d546699f
child 1453 3ca3071c2202
[test] add config file in tests following narval changes to use instance_id
test/data/narval-cw-sources.ini
test/unittest_apycot.py
test/utils.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/narval-cw-sources.ini	Tue Oct 22 21:47:29 2013 +0200
@@ -0,0 +1,4 @@
+[narval]
+url=http://testing.fr/cubicweb/
+user=narval
+password=narval0
--- a/test/unittest_apycot.py	Tue Oct 22 22:36:45 2013 +0200
+++ b/test/unittest_apycot.py	Tue Oct 22 21:47:29 2013 +0200
@@ -7,6 +7,12 @@
 
 from cubes.narval.logformat import log_to_html
 
+import os.path
+import narvalbot
+
+##override default ini file
+test_dir = os.path.dirname(__file__)
+narvalbot._CW_SOURCES_FILE = os.path.join(test_dir, 'data', 'narval-cw-sources.ini')
 
 CW_NAMESPACE_DIV = '<div xmlns:cubicweb="http://www.logilab.org/2008/cubicweb">%s</div>'
 
@@ -23,7 +29,7 @@
         te = self.lgc.start(self.lgce)
         self.commit()
         with self.login('narval', password='narval0') as cu:
-            cnxh = HTTPConnectionHandler('toto')
+            cnxh = HTTPConnectionHandler('narval')
             writer = TestDataWriter(cnxh, te.cwuri)
             writer.start()
             cwriter = writer.make_check_writer()
--- a/test/utils.py	Tue Oct 22 22:36:45 2013 +0200
+++ b/test/utils.py	Tue Oct 22 21:47:29 2013 +0200
@@ -1,7 +1,14 @@
 import shutil
+import os
 from datetime import datetime
 from os.path import join, dirname, abspath
 
+# MUST be done BEFORE importing narvalbot
+INPUTS_DIR = abspath(join(dirname(__file__), 'data'))
+def input_path(file=''):
+    return join(INPUTS_DIR, file)
+os.environ['NARVALSOURCES'] = input_path('narval-cw-sources.ini')
+
 from logilab.common.testlib import mock_object
 
 from cubicweb.devtools.testlib import CubicWebTC
@@ -11,10 +18,6 @@
 
 from apycotlib.writer import CheckDataWriter, BaseDataWriter
 
-INPUTS_DIR = abspath(join(dirname(__file__), 'data'))
-
-def input_path(file=''):
-    return join(INPUTS_DIR, file)
 
 
 class DummyStack(object):