diff --git a/pavelib/bok_choy.py b/pavelib/bok_choy.py index 30c150978c..ef7509c8e7 100644 --- a/pavelib/bok_choy.py +++ b/pavelib/bok_choy.py @@ -4,6 +4,7 @@ http://bok-choy.readthedocs.org/en/latest/ """ from paver.easy import task, needs, cmdopts, sh from pavelib.utils.test.suites.bokchoy_suite import BokChoyTestSuite, Pa11yCrawler +from pavelib.utils.test.bokchoy_options import BOKCHOY_OPTS, parse_bokchoy_opts from pavelib.utils.envs import Env from pavelib.utils.test.utils import check_firefox_version from pavelib.utils.passthrough_opts import PassthroughTask @@ -18,71 +19,6 @@ except ImportError: __test__ = False # do not collect -BOKCHOY_OPTS = [ - ('test-spec=', 't', 'Specific test to run'), - ('fasttest', 'a', 'Skip some setup'), - ('skip-clean', 'C', 'Skip cleaning repository before running tests'), - ('serversonly', 'r', 'Prepare suite and leave servers running'), - ('testsonly', 'o', 'Assume servers are running and execute tests only'), - ('default-store=', 's', 'Default modulestore'), - ('test-dir=', 'd', 'Directory for finding tests (relative to common/test/acceptance)'), - ('imports-dir=', 'i', 'Directory containing (un-archived) courses to be imported'), - ('num-processes=', 'n', 'Number of test threads (for multiprocessing)'), - ('verify-xss', 'x', 'Run XSS vulnerability tests'), - 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"), - make_option("--skip-firefox-version-validation", action='store_false', dest="validate_firefox_version"), - make_option("--save-screenshots", action='store_true', dest="save_screenshots"), - ('default_store=', None, 'deprecated in favor of default-store'), - ('extra_args=', 'e', 'deprecated, pass extra options directly in the paver commandline'), - ('imports_dir=', None, 'deprecated in favor of imports-dir'), - ('num_processes=', None, 'deprecated in favor of num-processes'), - ('skip_clean', None, 'deprecated in favor of skip-clean'), - ('test_dir=', None, 'deprecated in favor of test-dir'), - ('test_spec=', None, 'Specific test to run'), - ('verify_xss', None, 'deprecated in favor of verify-xss'), - make_option( - "--skip_firefox_version_validation", - action='store_false', - dest="validate_firefox_version", - help="deprecated in favor of --skip-firefox-version-validation" - ), - make_option( - "--save_screenshots", - action='store_true', - dest="save_screenshots", - help="deprecated in favor of save-screenshots" - ), -] - - -def parse_bokchoy_opts(options, passthrough_options=None): - """ - Parses bok choy options. - - Returns: dict of options. - """ - if passthrough_options is None: - passthrough_options = [] - - return { - 'test_spec': getattr(options, 'test_spec', None), - 'fasttest': getattr(options, 'fasttest', False), - 'num_processes': int(getattr(options, 'num_processes', 1)), - 'verify_xss': getattr(options, 'verify_xss', os.environ.get('VERIFY_XSS', False)), - 'serversonly': getattr(options, 'serversonly', False), - 'testsonly': getattr(options, 'testsonly', False), - 'default_store': getattr(options, 'default_store', os.environ.get('DEFAULT_STORE', 'split')), - 'verbosity': getattr(options, 'verbosity', 2), - 'extra_args': getattr(options, 'extra_args', ''), - 'pdb': getattr(options, 'pdb', False), - 'test_dir': getattr(options, 'test_dir', 'tests'), - 'imports_dir': getattr(options, 'imports_dir', None), - 'save_screenshots': getattr(options, 'save_screenshots', False), - 'passthrough_options': passthrough_options - } - @needs('pavelib.prereqs.install_prereqs') @cmdopts(BOKCHOY_OPTS) diff --git a/pavelib/utils/test/bokchoy_options.py b/pavelib/utils/test/bokchoy_options.py new file mode 100644 index 0000000000..b684c3ac48 --- /dev/null +++ b/pavelib/utils/test/bokchoy_options.py @@ -0,0 +1,68 @@ +from optparse import make_option +import os + + +BOKCHOY_OPTS = [ + ('test-spec=', 't', 'Specific test to run'), + ('fasttest', 'a', 'Skip some setup'), + ('skip-clean', 'C', 'Skip cleaning repository before running tests'), + ('serversonly', 'r', 'Prepare suite and leave servers running'), + ('testsonly', 'o', 'Assume servers are running and execute tests only'), + make_option("-s", "--default-store", default=os.environ.get('DEFAULT_STORE', 'split'), help='Default modulestore'), + ('test-dir=', 'd', 'Directory for finding tests (relative to common/test/acceptance)'), + ('imports-dir=', 'i', 'Directory containing (un-archived) courses to be imported'), + ('num-processes=', 'n', 'Number of test threads (for multiprocessing)'), + ('verify-xss', 'x', 'Run XSS vulnerability tests'), + 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"), + make_option("--skip-firefox-version-validation", action='store_false', dest="validate_firefox_version"), + make_option("--save-screenshots", action='store_true', dest="save_screenshots"), + make_option("--default_store", default=os.environ.get('DEFAULT_STORE', 'split'), help='deprecated in favor of default-store'), + ('extra_args=', 'e', 'deprecated, pass extra options directly in the paver commandline'), + ('imports_dir=', None, 'deprecated in favor of imports-dir'), + ('num_processes=', None, 'deprecated in favor of num-processes'), + ('skip_clean', None, 'deprecated in favor of skip-clean'), + ('test_dir=', None, 'deprecated in favor of test-dir'), + ('test_spec=', None, 'Specific test to run'), + ('verify_xss', None, 'deprecated in favor of verify-xss'), + make_option( + "--skip_firefox_version_validation", + action='store_false', + dest="validate_firefox_version", + help="deprecated in favor of --skip-firefox-version-validation" + ), + make_option( + "--save_screenshots", + action='store_true', + dest="save_screenshots", + help="deprecated in favor of save-screenshots" + ), +] + + +def parse_bokchoy_opts(options, passthrough_options=None): + """ + Parses bok choy options. + + Returns: dict of options. + """ + if passthrough_options is None: + passthrough_options = [] + + return { + 'test_spec': getattr(options, 'test_spec', None), + 'fasttest': getattr(options, 'fasttest', False), + 'num_processes': int(getattr(options, 'num_processes', 1)), + 'verify_xss': getattr(options, 'verify_xss', os.environ.get('VERIFY_XSS', False)), + 'serversonly': getattr(options, 'serversonly', False), + 'testsonly': getattr(options, 'testsonly', False), + 'default_store': getattr(options, 'default_store', os.environ.get('DEFAULT_STORE', 'split')), + 'verbosity': getattr(options, 'verbosity', 2), + 'extra_args': getattr(options, 'extra_args', ''), + 'pdb': getattr(options, 'pdb', False), + 'test_dir': getattr(options, 'test_dir', 'tests'), + 'imports_dir': getattr(options, 'imports_dir', None), + 'save_screenshots': getattr(options, 'save_screenshots', False), + 'passthrough_options': passthrough_options + }