From 6de73a34a755c58fc68a99adb09a01c1aee3c515 Mon Sep 17 00:00:00 2001 From: Roy Willy Haug Date: Fri, 8 Dec 2023 14:38:37 +0100 Subject: [PATCH] Adding more tests --- tests/test_uploads_from_komodo.py | 74 +++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/tests/test_uploads_from_komodo.py b/tests/test_uploads_from_komodo.py index 4741180..6044945 100644 --- a/tests/test_uploads_from_komodo.py +++ b/tests/test_uploads_from_komodo.py @@ -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 @@ -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 = ( @@ -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)) + \ No newline at end of file