test/test_functional.py
author David Douard <david.douard@logilab.fr>
Sun, 26 Oct 2014 18:30:36 +0100
changeset 1736 72ec6c7e956c
parent 1734 e3548d8d2868
child 1580 2f465d1682da
permissions -rw-r--r--
[apycotlib] port to narval 4.2 The connection handler is now a CWProxy (cwclientlib), and there is no CreateSubEntity view any more since we can now create File entity using cwclientlib and rqlcontroller.

import os
import os.path as osp
from shutil import rmtree

from logilab.common.shellutils import unzip
from logilab.common.testlib import unittest_main

import cubicweb.devtools
import cubes.apycot.testutils as utils
from cubes.apycot.recipes import full_script
from cubes.vcsfile.testutils import HGRCMixin

DATA = osp.join(osp.dirname(__file__), 'data')
os.environ['HGRCPATH'] = os.devnull

class ApycotTC(HGRCMixin, utils.ApycotBaseTC):
    _repo_path = u'project'

    def setUp(self):
        utils.setup_repos(DATA, self._repo_path)
        super(ApycotTC, self).setUp()


    def test_quick_recipe(self):
        with self.admin_access.client_cnx() as cnx:
            lgc = cnx.entity_from_eid(self.lgc)
            lgce = cnx.entity_from_eid(self.lgce)
            te = lgc.start(lgce).eid
            cnx.commit()
        self.run_plan(te)
        with self.admin_access.client_cnx() as cnx:
            te = cnx.entity_from_eid(te)
            self.assertEqual(dict((checker.name, checker.status) for checker in te.checkers),
                             {'pyunit': 'nodata'})

    def test_full_recipe(self):
        with self.admin_access.client_cnx() as cnx:
            lgce = cnx.entity_from_eid(self.lgce)
            recipe = cnx.execute('Recipe X WHERE X name "apycot.recipe.full"').get_entity(0, 0)
            # reset recipe content
            recipe.cw_set(script=full_script)
            tc = self.add_test_config(cnx, u'full config', env=self.lgce, group=self.pyp,
                                      use_recipe=recipe)
            te = tc.start(lgce).eid
            cnx.commit()
        self.run_plan(te)
        with self.admin_access.client_cnx() as cnx:
            te = cnx.entity_from_eid(te)
            exp = {u'pycoverage': u'error', u'pyunit': u'nodata'}
            try:
                # do only check pylint tests where executed if pylint
                # is available
                from pylint import checkers as pycheckers
                from pylint.lint import PyLinter
                from pylint.__pkginfo__ import version as pylint_version
                from pylint.interfaces import IReporter
                from pylint.reporters import BaseReporter
                exp['pylint'] = u'error'
            except:
                pass
            self.assertDictEqual(exp,
                                 dict((checker.name, checker.status) for checker in te.checkers),
                                 )

if __name__ == '__main__':
    unittest_main()