test/test_functional.py
author David Douard <david.douard@logilab.fr>
Tue, 21 Oct 2014 23:17:46 +0200
changeset 1738 dbf8a63bd907
parent 1736 72ec6c7e956c
child 1580 2f465d1682da
permissions -rw-r--r--
[recipe] improve recipes' comments

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()