Commit 2f577ad2e5387faa09ff2236a445c6ea6a817b0f

Authored by Alexis Koralewski
1 parent b52ba288
Exists in dev

Add option to run a specific function test & module of pyros

Showing 1 changed file with 14 additions and 5 deletions   Show diff stats
@@ -709,9 +709,9 @@ def install_or_update(UPDATE: bool = False, with_packages: bool = True, with_dat @@ -709,9 +709,9 @@ def install_or_update(UPDATE: bool = False, with_packages: bool = True, with_dat
709 709
710 710
711 @pyros_launcher.command(help="Run some tests") 711 @pyros_launcher.command(help="Run some tests")
712 -@click.option('--app', '-a', help='app name') 712 +@click.option('--module', '-m', help='module name')
713 @click.option('--function', '-f', help='function name') 713 @click.option('--function', '-f', help='function name')
714 -def test(app, function): 714 +def test(module, function):
715 print("Running tests") 715 print("Running tests")
716 os.environ["PATH_TO_OBSCONF_FOLDER"] = os.path.join( 716 os.environ["PATH_TO_OBSCONF_FOLDER"] = os.path.join(
717 os.path.abspath(PYROS_DJANGO_BASE_DIR), "obs_config/fixtures/") 717 os.path.abspath(PYROS_DJANGO_BASE_DIR), "obs_config/fixtures/")
@@ -723,7 +723,7 @@ def test(app, function): @@ -723,7 +723,7 @@ def test(app, function):
723 os.environ["pyros_config_file"] = os.path.join(os.path.abspath( 723 os.environ["pyros_config_file"] = os.path.join(os.path.abspath(
724 PYROS_DJANGO_BASE_DIR), "../../../config/general/default/", configfile) 724 PYROS_DJANGO_BASE_DIR), "../../../config/general/default/", configfile)
725 # start_dir = os.getcwd() 725 # start_dir = os.getcwd()
726 - if app == None: 726 + if module is None:
727 # apps = ['obs_config','scp_mgmt','common', 'scheduling', 'seq_submit', 'user_mgmt', 'alert_mgmt.tests.TestStrategyChange'] 727 # apps = ['obs_config','scp_mgmt','common', 'scheduling', 'seq_submit', 'user_mgmt', 'alert_mgmt.tests.TestStrategyChange']
728 # Removing alert_mgmt, scheduler from tests 728 # Removing alert_mgmt, scheduler from tests
729 apps = ['obs_config', "scp_mgmt", 729 apps = ['obs_config', "scp_mgmt",
@@ -732,9 +732,18 @@ def test(app, function): @@ -732,9 +732,18 @@ def test(app, function):
732 os.environ["PATH_TO_OBSCONF_FILE"] = os.path.join(os.path.abspath( 732 os.environ["PATH_TO_OBSCONF_FILE"] = os.path.join(os.path.abspath(
733 PYROS_DJANGO_BASE_DIR), "obs_config/fixtures/observatory_configuration_ok_simple.yml") 733 PYROS_DJANGO_BASE_DIR), "obs_config/fixtures/observatory_configuration_ok_simple.yml")
734 change_dir(PYROS_DJANGO_BASE_DIR) 734 change_dir(PYROS_DJANGO_BASE_DIR)
735 - cmd = 'manage.py test --keep --noinput --parallel 4 ' + app 735 + cmd = 'manage.py test --keep --noinput --parallel 4 ' + module
  736 + tests_classes = {
  737 + "obs_config": "ObservatoryConfigurationTests",
  738 + "scp_mgmt": "ScientificProgramTests",
  739 + "user_mgmt": "UserManagerTests",
  740 + "seq_submit": "SequencesTests",
  741 + "api": "APITests"
  742 +
  743 + }
736 if function: 744 if function:
737 - cmd += ".tests."+function 745 + test_class = tests_classes.get(module)
  746 + cmd += f".tests.{test_class}.{function}"
738 execProcessFromVenv( 747 execProcessFromVenv(
739 cmd, foreground=True) or die() 748 cmd, foreground=True) or die()
740 change_dir("PREVIOUS") 749 change_dir("PREVIOUS")