Skip to content

Commit

Permalink
Fix tests: use 2 similar surfaces for fast aggregation (adapt to serv…
Browse files Browse the repository at this point in the history
…er-side change) (#321)

* Fix tests: use 2 similar surfaces for fast aggregation  (adapt to server-side change)
  • Loading branch information
roywilly authored Apr 29, 2024
1 parent 4ab3c44 commit 7d44fee
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 17 deletions.
33 changes: 26 additions & 7 deletions tests/test_access/tst_access_drogon_manage_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Shall only run in Github Actions as a specific user with
specific access rights. Running this test with your personal login
will fail."""

import os
import json
import inspect
Expand Down Expand Up @@ -128,24 +129,43 @@ def test_aggregations_fast(explorer: Explorer):
assert len(cases) > 0
case = None
for c in cases:
if len(c.get_realizations()) > 1 and len(c.surfaces) > 40:
if (
len(c.get_realizations()) > 1
and len(c.surfaces) > 40
and len(c.iterations) == 1
and len(
c.surfaces.filter(
name="Therys Fm.", tagname="FACIES_Fraction_Calcite"
)
)
> 2
):
case = c
break
assert case
case_uuid = case.metadata.get("fmu").get("case").get("uuid")
print("About to trigger fast-aggregation on case", case_uuid)
surface_uuid = case.surfaces[0].uuid
print("using object_id of first surface:", surface_uuid)
surface1 = case.surfaces.filter(
name="Therys Fm.", realization=0, tagname="FACIES_Fraction_Calcite"
)
surface2 = case.surfaces.filter(
name="Therys Fm.", realization=1, tagname="FACIES_Fraction_Calcite"
)
print("Len filtered: ", len(surface1))
print("Len filtered: ", len(surface2))
assert len(surface1) == 1
assert len(surface2) == 1
surface_uuids = [surface1[0].uuid, surface2[0].uuid]
body = {
"operations": ["min"],
"object_ids": [surface_uuid],
"object_ids": surface_uuids,
"class": "surface",
"iteration_name": case.iterations[0].get("name"),
}
response = explorer._sumo.post(f"/aggregations", json=body)
print(response.status_code)
print("Response status code:", response.status_code)
assert response.status_code == 200
print(len(response.text))
print("Length of returned aggregate object:", len(response.text))


def test_get_access_log(explorer: Explorer):
Expand Down Expand Up @@ -190,4 +210,3 @@ def test_get_message_log_truncate(explorer: Explorer):
print("Execution should never reach this line")
print("Unexpected status: ", response.status_code)
print("Unexpected response: ", response.text)

32 changes: 26 additions & 6 deletions tests/test_access/tst_access_drogon_write_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Shall only run in Github Actions as a specific user with
specific access rights. Running this test with your personal login
will fail."""

import os
import json
import inspect
Expand Down Expand Up @@ -128,24 +129,43 @@ def test_aggregations_fast(explorer: Explorer):
assert len(cases) > 0
case = None
for c in cases:
if len(c.get_realizations()) > 1 and len(c.surfaces) > 40:
if (
len(c.get_realizations()) > 1
and len(c.surfaces) > 40
and len(c.iterations) == 1
and len(
c.surfaces.filter(
name="Therys Fm.", tagname="FACIES_Fraction_Calcite"
)
)
> 2
):
case = c
break
assert case
case_uuid = case.metadata.get("fmu").get("case").get("uuid")
print("About to trigger fast-aggregation on case", case_uuid)
surface_uuid = case.surfaces[0].uuid
print("using object_id of first surface:", surface_uuid)
surface1 = case.surfaces.filter(
name="Therys Fm.", realization=0, tagname="FACIES_Fraction_Calcite"
)
surface2 = case.surfaces.filter(
name="Therys Fm.", realization=1, tagname="FACIES_Fraction_Calcite"
)
print("Len filtered: ", len(surface1))
print("Len filtered: ", len(surface2))
assert len(surface1) == 1
assert len(surface2) == 1
surface_uuids = [surface1[0].uuid, surface2[0].uuid]
body = {
"operations": ["min"],
"object_ids": [surface_uuid],
"object_ids": surface_uuids,
"class": "surface",
"iteration_name": case.iterations[0].get("name"),
}
response = explorer._sumo.post(f"/aggregations", json=body)
print(response.status_code)
print("Response status code:", response.status_code)
assert response.status_code == 200
print(len(response.text))
print("Length of returned aggregate object:", len(response.text))


def test_get_access_log(explorer: Explorer):
Expand Down
11 changes: 7 additions & 4 deletions tests/test_access/tst_access_no_access_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Shall only run in Github Actions as a specific user with
specific access rights. Running this test with your personal login
will fail."""

import os
import json
import inspect
Expand Down Expand Up @@ -152,7 +153,7 @@ def test_aggregate_bulk(explorer: Explorer):
"case_uuid": TESTCASE_UUID,
"class": "surface",
"iteration_name": "iter-0",
}
}
with pytest.raises(Exception, match="40*"):
response = explorer._sumo.post(f"/aggregations", json=body)
print("Execution should never reach this line")
Expand All @@ -166,14 +167,16 @@ def test_aggregations_fast(explorer: Explorer):
# Fixed test case ("Drogon_AHM_2023-02-22") in Sumo/DEV
TESTCASE_UUID = "10f41041-2c17-4374-a735-bb0de62e29dc"
print("About to trigger fast-aggregation on case", TESTCASE_UUID)
SURFACE_UUID = "ae6cf480-12ba-77ca-848e-92e707556b63"
print("using object_id of first surface:", SURFACE_UUID)
SURFACE_UUID_1 = "ae6cf480-12ba-77ca-848e-92e707556b63"
SURFACE_UUID_2 = "7189835b-cc8a-2a8e-4a34-dde2ceb2a69c"
body = {
"operations": ["min"],
"object_ids": [SURFACE_UUID],
"object_ids": [SURFACE_UUID_1, SURFACE_UUID_2],
"class": "surface",
"iteration_name": "iter-0",
}
print("About to trigger fast-aggregation on hardcoded case", TESTCASE_UUID)
print("using body", body)
with pytest.raises(Exception, match="40*"):
response = explorer._sumo.post(f"/aggregations", json=body)
print("Execution should never reach this line")
Expand Down

0 comments on commit 7d44fee

Please sign in to comment.