acceptance_test.py 2.08 KB
Newer Older
1 2 3
"""
Acceptance test tasks
"""
4 5
from optparse import make_option

6
from paver.easy import cmdopts, needs
7

8
from pavelib.utils.passthrough_opts import PassthroughTask
9
from pavelib.utils.test.suites import AcceptanceTestSuite
10
from pavelib.utils.timer import timed
11 12 13 14

try:
    from pygments.console import colorize
except ImportError:
15
    colorize = lambda color, text: text
16 17 18

__test__ = False  # do not collect

19

20 21 22 23 24 25
@needs(
    'pavelib.prereqs.install_prereqs',
    'pavelib.utils.test.utils.clean_reports_dir',
)
@cmdopts([
    ("system=", "s", "System to act on"),
26
    ("default-store=", "m", "Default modulestore to use for course creation"),
27 28 29 30
    ("fasttest", "a", "Run without collectstatic"),
    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"),
31
    ("default_store=", None, "deprecated in favor of default-store"),
32
    ('extra_args=', 'e', 'deprecated, pass extra options directly in the paver commandline'),
33
])
34
@PassthroughTask
35
@timed
36
def test_acceptance(options, passthrough_options):
37
    """
38
    Run the acceptance tests for either lms or cms
39 40 41 42
    """
    opts = {
        'fasttest': getattr(options, 'fasttest', False),
        'system': getattr(options, 'system', None),
43
        'default_store': getattr(options, 'default_store', None),
44 45
        'verbosity': getattr(options, 'verbosity', 3),
        'extra_args': getattr(options, 'extra_args', ''),
46
        'pdb': getattr(options, 'pdb', False),
47
        'passthrough_options': passthrough_options,
48 49 50 51 52 53 54
    }

    if opts['system'] not in ['cms', 'lms']:
        msg = colorize(
            'red',
            'No system specified, running tests for both cms and lms.'
        )
55
        print msg
56 57 58 59 60
    if opts['default_store'] not in ['draft', 'split']:
        msg = colorize(
            'red',
            'No modulestore specified, running tests for both draft and split.'
        )
61
        print msg
62 63 64

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