test/test_functional.py
author David Douard <david.douard@logilab.fr>
Sun, 26 Oct 2014 00:26:31 +0200
changeset 1759 b9915807bddb
parent 1758 b1b931406fb2
child 1609 e1c8520e7962
permissions -rw-r--r--
kill preprocessor, since there is nothing left there Preprocessing is now handled via dedicated recipes.

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

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

    def test_quick_recipe_no_data(self):
        with self.admin_access.client_cnx() as cnx:
            tc = cnx.find('TestConfig', name='tc_project1').one()
            pe = cnx.fond('ProjectEnviironment', name='pe_project1').one()
            te = tc.start(pe).eid
            cnx.commit()
        self.run_plan(te)
        with self.admin_access.client_cnx() as cnx:
            te = cnx.entity_from_eid(te)
            expected = {'pyunit': 'nodata'}
            for checker in te.checkers:
                self.assertEqual(expected[checker.name], checker.status, checker.log_file[0].read())

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