test/test_apycot.py
author David Douard <david.douard@logilab.fr>
Sun, 26 Oct 2014 18:30:36 +0100
changeset 1736 72ec6c7e956c
parent 713 404a829790be
child 1592 afc8a9980d43
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.

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