From 39b12984733ca2030d011fdcec3b4c32c6a88c6f Mon Sep 17 00:00:00 2001 From: Roy Willy Haug Date: Fri, 8 Dec 2023 11:01:51 +0100 Subject: [PATCH] Minor impr --- .../run_tests_uploads_from_komodo.yaml | 4 +- tests/test_uploads_from_komodo.py | 79 ++++++------------- 2 files changed, 28 insertions(+), 55 deletions(-) diff --git a/.github/workflows/run_tests_uploads_from_komodo.yaml b/.github/workflows/run_tests_uploads_from_komodo.yaml index 3c7588a..e66b057 100644 --- a/.github/workflows/run_tests_uploads_from_komodo.yaml +++ b/.github/workflows/run_tests_uploads_from_komodo.yaml @@ -12,8 +12,8 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] - os: [ubuntu-latest, windows-latest] + python-version: ["3.11"] + os: [ubuntu-latest] permissions: contents: read id-token: write diff --git a/tests/test_uploads_from_komodo.py b/tests/test_uploads_from_komodo.py index 544afad..f2f1d6f 100644 --- a/tests/test_uploads_from_komodo.py +++ b/tests/test_uploads_from_komodo.py @@ -27,25 +27,11 @@ logger.setLevel(level="DEBUG") -# class SumoConnection: -# def __init__(self, env, token=None): -# self.env = env -# self._connection = None -# self.token = token - -# @property -# def connection(self): -# if self._connection is None: -# self._connection = uploader.SumoConnection( -# env=self.env, token=self.token) -# return self._connection - - def _get_latest_case(explorer): """Returns latest f_scout_ci case that was uploaded from komodo-releases""" cases = explorer.cases cases = cases.filter(user="f_scout_ci") - assert (len(cases) > 0) + assert len(cases) > 0 newest_date = "1000-01-01T00:00:00.000Z" newest_case = cases[0] for case in cases: @@ -54,52 +40,39 @@ def _get_latest_case(explorer): newest_date = metadata["_sumo"]["timestamp"] newest_case = case - print ("Newest case: ", newest_case.uuid, " ", newest_case.name) + print("Newest case: ", newest_case.uuid, " ", newest_case.name) return newest_case -# sumo = Explorer(env=ENV) -# case = _get_latest_case() - @pytest.fixture(name="explorer") def fixture_explorer(token: str) -> Explorer: """Returns explorer""" return Explorer("dev", token=token) -### TESTS ### - - - def test_case(explorer: Explorer): + """Test the latest case uploaded by komodo-explorer. + We know how many objects etc we should find.""" case = _get_latest_case(explorer) - assert(case) - number_of_children = len(case.cubes) + len(case.polygons) + len(case.surfaces) + len(case.dictionaries) + len(case.tables) - assert(number_of_children > 110) - assert(len(case.surfaces) > 53) - assert(len(case.cubes) > 9) - assert(len(case.tables) > 6) - assert(len(case.polygons) > 5000) - assert(len(case.dictionaries) > 0) - -# def test_case_have_enough_children_in_total(): -# # We know that komodo-releases uploads 111 child objects in total -# number_of_children = len(case.cubes) + len(case.polygons) + len(case.surfaces) + len(case.dictionaries) + len(case.tables) -# assert(number_of_children > 110) - -# def test_case_have_enough_surfaces(): -# assert(len(case.surfaces) > 53) - -# def test_case_have_enough_cubes(): -# assert(len(case.cubes) > 9) - -# def test_case_have_enough_tables(): -# assert(len(case.tables) > 6) - -# def test_case_have_enough_polygons(): -# assert(len(case.polygons) > 5) - -# def test_case_have_enough_dictionaries(): -# assert(len(case.dictionaries) > 0) - - + assert case + number_of_children = ( + len(case.cubes) + + len(case.polygons) + + len(case.surfaces) + + len(case.dictionaries) + + len(case.tables) + ) + assert number_of_children > 110 + assert len(case.surfaces) > 53 + assert len(case.cubes) > 9 + assert len(case.tables) > 6 + assert len(case.polygons) > 5 + assert len(case.dictionaries) > 0 + + case_timestamp = case.metadata["_sumo"]["timestamp"] + one_day_ago = datetime.now() - timedelta(days=1) + print("Timestamp of latest case: ", case_timestamp) + print(one_day_ago.strftime("%Y-%m-%dT%H:%M")) + # Verify that the case is new enough + # If this assert fails, check komodo-releases Github Actions + assert case_timestamp > one_day_ago.strftime("%Y-%m-%dT%H:%M")