test/test_apycot.py
author David Douard <david.douard@logilab.fr>
Wed, 14 May 2014 22:28:57 +0200
changeset 1520 0abe241164e2
parent 713 404a829790be
child 1592 afc8a9980d43
permissions -rw-r--r--
[test] fix tests when executed in an apycot environment ie. when tests are executed from sources towards an installed apycot. The fix consist mainly in "moving" the input_path function from testutils.py (which is part of the installed modules) into unittest_checkers.py so we are sure we look for test data files relatively to the test directory (and not the location of the installation).

"""cube automatic tests"""

from random import choice
from logilab.common.testlib import unittest_main

from cubicweb.devtools.fill import ValueGenerator
from cubicweb.devtools.testlib import AutomaticWebTest


class MyValueGenerator(ValueGenerator):
    def generate_Any_check_config(self, entity, index):
        return u'pylint_threshold=70\ninstall=python_setup'
    def generate_Any_check_environment(self, entity, index):
        return u'NO_SETUPTOOLS=1'
    def generate_TestConfig_start_mode(self, entity, index):
        return choice((u'manual', u'on new revision',
                       u'hourly', u'daily', u'weekly', u'monthly'))


class AutomaticWebTest(AutomaticWebTest):
    no_auto_populate = set(('Repository', 'Revision', 'VersionedFile',
                            'VersionContent', 'DeletedVersionContent',
                            'TestExecution', 'Plan', 'CheckResult', 'CheckResultInfo'))
    ignored_relations = set(('at_revision', 'parent_revision',
                             'from_repository', 'from_revision', 'content_for',
                             'nosy_list', 'execution_of'))

    def setUp(self):
        super(AutomaticWebTest, self).setUp()
        for etype in ('TestExecution', 'CheckResult', 'CheckResultInfo'):
            type_def = self.schema[etype]
            type_def.set_action_permissions('add', ('managers',))
            type_def.set_action_permissions('update', ('managers',))
        for rtype in ('using_config', 'during_execution', 'for_check'):
            for rdef in self.schema[rtype].rdefs.values():
                rdef.set_action_permissions('add', ('managers',))

    def to_test_etypes(self):
        return set(('ProjectEnvironment', 'TestConfig',
                    'TestExecution', 'CheckResult', 'CheckResultInfo'))

    def list_startup_views(self):
        return ()

if __name__ == '__main__':
    unittest_main()