--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/unittest_preprocessors.py Fri Apr 18 18:12:56 2014 +0200
@@ -0,0 +1,85 @@
+# -*- coding: utf-8 -*-
+
+from cubes.apycot.testutils import ApycotBaseTC
+
+import json
+from apycotlib import atest, writer, REGISTRY
+from apycotlib.preprocessors import distutils
+from cubicweb.utils import json_dumps
+
+class FakeCnxh(object):
+ def __init__(self, msgcfg, msgdep):
+ self.msgcfg = msgcfg
+ self.msgdep = msgdep
+ self.instance_url = 'http://gna'
+ def http_post(self, *args, **kwargs):
+ if 'vid' in kwargs and kwargs['vid'] == 'apycot.get_configuration':
+ return self.msgcfg
+ elif 'vid' in kwargs and kwargs['vid'] == 'apycot.get_dependencies':
+ return self.msgdep
+ else:
+ return []
+
+ def http_get(*args, **kwargs):
+ return [{'deps': 'a'}]
+
+REGISTRY['preprocessor']['python_setup'] = distutils.DistutilsProcessor
+
+class FakeWriter(object):
+ def debug(self, msg, *args, **kwargs):
+ pass
+ def info(self, msg, *args, **kwargs):
+ pass
+ def fatal(self, msg, *args, **kwargs):
+ pass
+
+ def __init__(self, msgcfg, msgdep):
+ self._cnxh = FakeCnxh(msgcfg, msgdep)
+
+class FileCheckerTest(ApycotBaseTC):
+ def start_lgc_tests(self):
+ plan = self.lgc.start(self.lgce)
+ self.lgc._cw.cnx.commit()
+ return plan
+
+ def test_exec_status_change(self):
+ req = self.request()
+ tc = req.create_entity('TestConfig',
+ name=u'TC',
+ label=u'full python tests',
+ start_mode=u'manual',
+ check_config=u"""pylint_threshold=7
+pycoverage_threshold=70
+install=python_setup""")
+ pe = req.create_entity('ProjectEnvironment',
+ name=u'gna',
+ reverse_use_environment=tc.eid,
+ local_repository=self.vcsrepo)
+
+ self.vcsrepo2 = req.create_entity('Repository', type=u'mercurial',
+ # use path to avoid clone attempt when using url
+ path=unicode(self.datapath('project1')), source_url=u'http://gna.com',
+ reverse_local_repository=self.lgce)
+
+ pe_dep1 = req.create_entity('ProjectEnvironment',
+ name=u'regna',
+ reverse_use_environment=tc.eid,
+ local_repository=self.vcsrepo2)
+
+
+ self.commit()
+ self.vreg['views']
+ req_env = self.request(environment=pe.eid)
+ req_env_dep = self.request(environment=pe_dep1.eid)
+ tconf = json.loads(req_env.view('apycot.get_configuration', rset=tc.as_rset()))
+ penv = json.loads(req_env.view('ejsonexport', rset=pe.as_rset()))[0]
+ penv_dep = json.loads(req_env.view('ejsonexport', rset=pe.as_rset()))
+ penv['title'] = 'gna'
+ self.login('narval', password='narval0')
+ plan = self.start_lgc_tests()
+ plan = json.loads(json_dumps(req.entity_from_eid(plan.eid)))
+ test = atest.Test(plan, FakeWriter(tconf, penv_dep))
+ test.call_preprocessor('install', penv)
+
+
+