Skip to content

Commit

Permalink
Adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
roywilly committed Dec 8, 2023
1 parent 4ac78f6 commit 6de73a3
Showing 1 changed file with 66 additions and 8 deletions.
74 changes: 66 additions & 8 deletions tests/test_uploads_from_komodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,17 @@

def _get_latest_case(explorer):
"""Returns latest f_scout_ci case that was uploaded from komodo-releases"""

cases = explorer.cases
cases.users
cases = cases.filter(user="f_scout_ci")
assert len(cases) > 0
newest_date = "1000-01-01T00:00:00.000Z"
newest_case = cases[0]
for case in cases:
metadata = case.metadata
if case.uuid == "4aea3bfb-5a7d-4b9d-92c1-8b68d73213cc":
return case
if metadata["_sumo"]["timestamp"] > newest_date:
newest_date = metadata["_sumo"]["timestamp"]
newest_case = case
Expand All @@ -51,8 +55,8 @@ def fixture_explorer(token: str) -> Explorer:


def test_case(explorer: Explorer):
"""Test the latest case uploaded by komodo-explorer.
We know how many objects etc we should find."""
"""Test the latest case uploaded by komodo-releases.
We hardcode how many objects etc we expect."""
case = _get_latest_case(explorer)
assert case
number_of_children = (
Expand All @@ -63,16 +67,70 @@ def test_case(explorer: Explorer):
+ len(case.tables)
)
assert number_of_children > 110
assert len(case.surfaces) > 53
assert len(case.surfaces) > 86
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)
yesterday = 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") # Case is too old
# Use tracklog.datetime instead of _sumo.timestamp?
# Verify that the case is new enough:
# If this assert fails, check komodo-releases Github Actions:
assert case_timestamp > yesterday.strftime("%Y-%m-%dT%H:%M")

# Verify surfaces
iter_count = 0
real_count = 0
for surf in case.surfaces:
assert surf.uuid
assert surf.name
assert surf.tagname
if surf.iteration is not None:
iter_count += 1
if surf.realization is not None:
real_count += 1
assert iter_count > 53
assert real_count > 53

# Avoid download of all surfaces here;
# use first surface blob only
reg = case.surfaces[0].to_regular_surface()
mean = reg.values.mean()

# TODO: Verify the other object types?


def test_case_seismic(explorer: Explorer):
"""Test the latest case uploaded by komodo-releases.
We hardcode how many objects etc we expect."""
case = _get_latest_case(explorer)
assert case
assert len(case.cubes) > 9

# Verify surfaces
iter_count = 0
real_count = 0
for cube in case.cubes:
assert cube.uuid
assert cube.name
assert cube.tagname
if cube.iteration is not None:
iter_count += 1
if cube.realization is not None:
real_count += 1
assert iter_count > 9
assert real_count > 9

# Avoid download of all cubes here;
# use first cube blob only
cube = case.cubes[0]
handle = cube.openvds_handle
layout = openvds.getLayout(handle)
channel_count = layout.getChannelCount()
assert channel_count > 0
# for i in range(channel_count):
# print(" ", layout.getChannelName(i))

0 comments on commit 6de73a3

Please sign in to comment.