Skip to content

Commit

Permalink
Minor impr
Browse files Browse the repository at this point in the history
  • Loading branch information
roywilly committed Dec 8, 2023
1 parent 6dc1966 commit 39b1298
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run_tests_uploads_from_komodo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
79 changes: 26 additions & 53 deletions tests/test_uploads_from_komodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")

0 comments on commit 39b1298

Please sign in to comment.