From f728e3c6454704171d96695227d4487adba3f6f4 Mon Sep 17 00:00:00 2001 From: Roy Willy Haug Date: Thu, 8 Feb 2024 12:29:42 +0100 Subject: [PATCH] Updates --- .../tst_access_drogon_manage_login.py | 1 - .../tst_access_drogon_read_login.py | 38 ++++++++++--------- .../tst_access_drogon_write_login.py | 1 - .../test_access/tst_access_no_access_login.py | 35 ++++++++++++++++- 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/tests/test_access/tst_access_drogon_manage_login.py b/tests/test_access/tst_access_drogon_manage_login.py index 4a070567..aeaf4664 100644 --- a/tests/test_access/tst_access_drogon_manage_login.py +++ b/tests/test_access/tst_access_drogon_manage_login.py @@ -110,7 +110,6 @@ def test_aggregations_bulk(explorer: Explorer): } response = explorer._sumo.post(f"/aggregations", json=body) print(response.status_code) - print(response.text) assert response.status_code == 200 assert response.json().get("batchType") == "batch" diff --git a/tests/test_access/tst_access_drogon_read_login.py b/tests/test_access/tst_access_drogon_read_login.py index 311a554b..cfc5c198 100644 --- a/tests/test_access/tst_access_drogon_read_login.py +++ b/tests/test_access/tst_access_drogon_read_login.py @@ -93,46 +93,50 @@ def test_read_restricted_classification_data(explorer: Explorer): print("Hits on restricted:", hits) assert hits == 0 -def test_aggregate_bulk(explorer: Explorer): - """Test a bulk aggregation method""" + +def test_aggregations_fast(explorer: Explorer): + """Test a fast aggregation method""" print("Running test:", inspect.currentframe().f_code.co_name) cases = explorer.cases print("Number of cases: ", len(cases)) assert len(cases) > 0 case = cases[0] case_uuid = case.metadata.get("fmu").get("case").get("uuid") - print("About to trigger aggregation on case", case_uuid) + print("About to trigger fast-aggregation on case", case_uuid) + surface_uuid = cases[0].surfaces[0].uuid + print("using object_id of first surface:", surface_uuid) body = { "operations": [ "min" ], - "case_uuid": case_uuid, + "object_ids": [ surface_uuid ], "class": "surface", "iteration_name": "iter-0" } response = explorer._sumo.post(f"/aggregations", json=body) print(response.status_code) - print(response.text) - assert response.status_code == 200 - assert response.json().get("batchType") == "batch" - print("TODO SHOULD FAIL") + assert response.status_code in [200, 201, 202] + print(len(response.text)) -def test_aggregations_fast(explorer: Explorer): - """Test a fast aggregation method""" + +def test_aggregate_bulk(explorer: Explorer): + """Test a bulk aggregation method""" print("Running test:", inspect.currentframe().f_code.co_name) cases = explorer.cases print("Number of cases: ", len(cases)) assert len(cases) > 0 case = cases[0] case_uuid = case.metadata.get("fmu").get("case").get("uuid") - print("About to trigger fast-aggregation on case", case_uuid) - surface_uuid = cases[0].surfaces[0].uuid - print("using object_id of first surface:", surface_uuid) + print("About to trigger aggregation on case", case_uuid) body = { "operations": [ "min" ], - "object_ids": [ surface_uuid ], + "case_uuid": case_uuid, "class": "surface", - "iteration_name": "iter-0" + "iteration_name": case.iterations[0].get("name") } + print("lkjlkjlkjlkjlkj", case.iterations[0].get("name")) response = explorer._sumo.post(f"/aggregations", json=body) print(response.status_code) - assert response.status_code == 200 - print(len(response.text)) + print(response.text) + assert response.status_code not in [200, 201, 202] + assert response.json().get("batchType") != "batch" + print("TODO SHOULD FAIL") + diff --git a/tests/test_access/tst_access_drogon_write_login.py b/tests/test_access/tst_access_drogon_write_login.py index 4f78215e..7f2cc1bf 100644 --- a/tests/test_access/tst_access_drogon_write_login.py +++ b/tests/test_access/tst_access_drogon_write_login.py @@ -109,7 +109,6 @@ def test_aggregate_bulk(explorer: Explorer): } response = explorer._sumo.post(f"/aggregations", json=body) print(response.status_code) - print(response.text) assert response.status_code == 200 assert response.json().get("batchType") == "batch" diff --git a/tests/test_access/tst_access_no_access_login.py b/tests/test_access/tst_access_no_access_login.py index a781bceb..20df6916 100644 --- a/tests/test_access/tst_access_no_access_login.py +++ b/tests/test_access/tst_access_no_access_login.py @@ -107,9 +107,42 @@ def test_get_access_log(explorer: Explorer): print(response.status_code) print(response.text) print(len(response.text)) - print("TODO SHOULD FAIL????") + # Currently all authenticated users have access assert response.status_code == 200 +def test_get_key(explorer: Explorer): + """Test to get key method""" + print("Running test:", inspect.currentframe().f_code.co_name) + print("About to get key ") + response = explorer._sumo.post(f"/key") + print(response.status_code) + print(response.text) + print(len(response.text)) + print("TODO SHOULD FAIL") + # assert response.status_code == 999 + +def test_get_purge(explorer: Explorer): + """Test to get purge method""" + print("Running test:", inspect.currentframe().f_code.co_name) + print("About to get purge ") + response = explorer._sumo.post(f"/purge") + print(response.status_code) + print(response.text) + print(len(response.text)) + print("TODO should fail") + # assert response.status_code == 999 + +def test_get_message_log_truncate(explorer: Explorer): + """Test to get msg log truncate method""" + print("Running test:", inspect.currentframe().f_code.co_name) + print("About to get msg log truncate ") + response = explorer._sumo.post(f"/message-log/truncate?cutoff=99") + print(response.status_code) + print(response.text) + print(len(response.text)) + print("TODO should fail") + # assert response.status_code == 999 + def test_aggregate_bulk(explorer: Explorer): """Test a bulk aggregation method"""