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

"""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',
                            'TestExecution', 'Plan', 'CheckResult', 'CheckResultInfo'))
    ignored_relations = set(('parent_revision',
                             'from_repository',
                             'nosy_list'))

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