acceptance_test.py 1.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
"""
Acceptance test tasks
"""
from paver.easy import task, cmdopts, needs
from pavelib.utils.test.suites import AcceptanceTestSuite
from optparse import make_option

try:
    from pygments.console import colorize
except ImportError:
    colorize = lambda color, text: text  # pylint: disable-msg=invalid-name

__test__ = False  # do not collect

15

16 17 18 19 20 21 22
@task
@needs(
    'pavelib.prereqs.install_prereqs',
    'pavelib.utils.test.utils.clean_reports_dir',
)
@cmdopts([
    ("system=", "s", "System to act on"),
23
    ("default_store=", "m", "Default modulestore to use for course creation"),
24 25 26 27 28 29 30 31 32 33 34 35 36
    ("fasttest", "a", "Run without collectstatic"),
    ("extra_args=", "e", "adds as extra args to the test command"),
    make_option("--verbose", action="store_const", const=2, dest="verbosity"),
    make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
    make_option("-v", "--verbosity", action="count", dest="verbosity"),
])
def test_acceptance(options):
    """
    Run the acceptance tests for the either lms or cms
    """
    opts = {
        'fasttest': getattr(options, 'fasttest', False),
        'system': getattr(options, 'system', None),
37
        'default_store': getattr(options, 'default_store', None),
38 39 40 41 42 43 44 45 46 47
        'verbosity': getattr(options, 'verbosity', 3),
        'extra_args': getattr(options, 'extra_args', ''),
    }

    if opts['system'] not in ['cms', 'lms']:
        msg = colorize(
            'red',
            'No system specified, running tests for both cms and lms.'
        )
        print(msg)
48 49 50 51 52 53
    if opts['default_store'] not in ['draft', 'split']:
        msg = colorize(
            'red',
            'No modulestore specified, running tests for both draft and split.'
        )
        print(msg)
54 55 56

    suite = AcceptanceTestSuite('{} acceptance'.format(opts['system']), **opts)
    suite.run()