From 97b756dbcb4af5b14addf394129e12f0ad6103ea Mon Sep 17 00:00:00 2001 From: Mitchel Baker Date: Fri, 26 Jul 2024 20:08:54 +0000 Subject: [PATCH] workflow updates --- .github/workflows/run_smoke_test.yml | 6 ++++-- Testing/Functional/SmokeTests/smoke_test.py | 16 +++----------- .../Functional/SmokeTests/smoke_test_utils.py | 21 ++++++++++--------- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/.github/workflows/run_smoke_test.yml b/.github/workflows/run_smoke_test.yml index b5cb3995..21ddc50c 100644 --- a/.github/workflows/run_smoke_test.yml +++ b/.github/workflows/run_smoke_test.yml @@ -42,14 +42,16 @@ jobs: python -m venv .venv .venv\Scripts\activate - - name: Install project dependencies and OPA + - name: Install dependencies run: | python -m pip install . pip install -r requirements.txt pip install pytest pip uninstall numpy pip install numpy==1.26.4 - python download_opa.py -v 0.60.0 -os windows + + - name: Download OPA executable + run: python download_opa.py -v 0.60.0 -os windows - name: Execute ScubaGoggles and check for correct output run: | diff --git a/Testing/Functional/SmokeTests/smoke_test.py b/Testing/Functional/SmokeTests/smoke_test.py index 99354261..d117e110 100644 --- a/Testing/Functional/SmokeTests/smoke_test.py +++ b/Testing/Functional/SmokeTests/smoke_test.py @@ -12,15 +12,12 @@ class SmokeTest: def test_venv_creation(self): try: - result = subprocess.run(["ls", ".venv"], shell=True, capture_output=True, text=True) + result = subprocess.run(["ls", ".venv"], shell=True, capture_output=True, text=True, check=True) if "Scripts" in result.stdout: assert True - else: - assert False, f"Scripts was not found in the virtual environment" - except Exception as e: + except subprocess.CalledProcessError as e: pytest.fail(f"An error occurred, {e}") - def test_scubagoggles(self, subjectemail): try: command = f"scubagoggles gws --subjectemail {subjectemail} --quiet" @@ -33,17 +30,10 @@ def test_scubagoggles(self, subjectemail): cwd = os.getcwd() output_path = os.path.join(cwd, directories[0]) contents = verify_output_type(output_path, []) - print(contents) verify_all_outputs_exist(contents) - except Exception as e: + except (OSError, ValueError, Exception) as e: pytest.fail(f"An error occurred, {e}") - - - - - - #def create_venv(env): # result = subprocess.run(["python", "-m", "venv", env]) # if result.returncode == 0: diff --git a/Testing/Functional/SmokeTests/smoke_test_utils.py b/Testing/Functional/SmokeTests/smoke_test_utils.py index 2bea85d0..ed738900 100644 --- a/Testing/Functional/SmokeTests/smoke_test_utils.py +++ b/Testing/Functional/SmokeTests/smoke_test_utils.py @@ -1,9 +1,10 @@ +import pytest import os required_contents = [ "BaselineReports.html", "IndividualReports", - "ScubaResults.json", + "ProviderExport.json", "TestResults.json", "images", "CalendarReport.html", @@ -20,13 +21,6 @@ "triangle-exclamation-solid.svg" ] -def verify_all_outputs_exist(contents): - for required_content in required_contents: - if required_content in contents: - assert True - else: - assert False, f"{required_content} was not found in the generated report" - def verify_output_type(output_path, contents): entries = os.listdir(output_path) @@ -41,6 +35,13 @@ def verify_output_type(output_path, contents): elif os.path.isfile(child_path): assert True else: - assert False, f"Entry is not a directory or file (symlink, etc.)" + raise OSError(f"Entry is not a directory or file (symlink, etc.)") - return contents \ No newline at end of file + return contents + +def verify_all_outputs_exist(contents): + for required_content in required_contents: + if required_content in contents: + assert True + else: + raise ValueError(f"{required_content} was not found in the generated report") \ No newline at end of file