From 2f577ad2e5387faa09ff2236a445c6ea6a817b0f Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Mon, 26 Jun 2023 11:01:56 +0200 Subject: [PATCH] Add option to run a specific function test & module of pyros --- pyros.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/pyros.py b/pyros.py index eecbe84..36731f2 100755 --- a/pyros.py +++ b/pyros.py @@ -709,9 +709,9 @@ def install_or_update(UPDATE: bool = False, with_packages: bool = True, with_dat @pyros_launcher.command(help="Run some tests") -@click.option('--app', '-a', help='app name') +@click.option('--module', '-m', help='module name') @click.option('--function', '-f', help='function name') -def test(app, function): +def test(module, function): print("Running tests") os.environ["PATH_TO_OBSCONF_FOLDER"] = os.path.join( os.path.abspath(PYROS_DJANGO_BASE_DIR), "obs_config/fixtures/") @@ -723,7 +723,7 @@ def test(app, function): os.environ["pyros_config_file"] = os.path.join(os.path.abspath( PYROS_DJANGO_BASE_DIR), "../../../config/general/default/", configfile) # start_dir = os.getcwd() - if app == None: + if module is None: # apps = ['obs_config','scp_mgmt','common', 'scheduling', 'seq_submit', 'user_mgmt', 'alert_mgmt.tests.TestStrategyChange'] # Removing alert_mgmt, scheduler from tests apps = ['obs_config', "scp_mgmt", @@ -732,9 +732,18 @@ def test(app, function): os.environ["PATH_TO_OBSCONF_FILE"] = os.path.join(os.path.abspath( PYROS_DJANGO_BASE_DIR), "obs_config/fixtures/observatory_configuration_ok_simple.yml") change_dir(PYROS_DJANGO_BASE_DIR) - cmd = 'manage.py test --keep --noinput --parallel 4 ' + app + cmd = 'manage.py test --keep --noinput --parallel 4 ' + module + tests_classes = { + "obs_config": "ObservatoryConfigurationTests", + "scp_mgmt": "ScientificProgramTests", + "user_mgmt": "UserManagerTests", + "seq_submit": "SequencesTests", + "api": "APITests" + + } if function: - cmd += ".tests."+function + test_class = tests_classes.get(module) + cmd += f".tests.{test_class}.{function}" execProcessFromVenv( cmd, foreground=True) or die() change_dir("PREVIOUS") -- libgit2 0.21.2