From 4f90fb1a69109975a2931e83b02009f4f267ec80 Mon Sep 17 00:00:00 2001 From: Hans Kallekleiv <16436291+HansKallekleiv@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:41:20 +0200 Subject: [PATCH] wip --- .github/workflows/backend_sumo_prod.yml | 7 ++++--- backend_py/primary/primary/config.py | 3 +-- backend_py/primary/pyproject.toml | 1 + .../primary/tests/integration/conftest.py | 7 +++---- .../routers/explore/test_explore.py | 9 +++++++++ .../test_get_realizations_vector_data.py | 18 +++++++++--------- .../routers/timeseries/test_get_vector_list.py | 10 +++------- 7 files changed, 30 insertions(+), 25 deletions(-) create mode 100644 backend_py/primary/tests/integration/routers/explore/test_explore.py diff --git a/.github/workflows/backend_sumo_prod.yml b/.github/workflows/backend_sumo_prod.yml index 4cb2fb4ac..361abe3b2 100644 --- a/.github/workflows/backend_sumo_prod.yml +++ b/.github/workflows/backend_sumo_prod.yml @@ -61,11 +61,12 @@ jobs: WEBVIZ_VDS_HOST_ADDRESS: 0 WEBVIZ_ENTERPRISE_SUBSCRIPTION_KEY: 0 WEBVIZ_SSDL_RESOURCE_SCOPE: 0 - sharedkey_sumo_prod: ${{ secrets.SHARED_KEY_DROGON_READ_PROD }} + WEBVIZ_SUMU_ENV: prod + SHARED_KEY_SUMO_PROD: ${{ secrets.SHARED_KEY_DROGON_READ_PROD }} run: | - echo "Length of sharedkey_sumo_prod variable read from Github Secrets:" ${#sharedkey_sumo_prod} + echo "Length of SHARED_KEY_SUMO_PROD variable read from Github Secrets:" ${#SHARED_KEY_SUMO_PROD} mkdir ~/.sumo - echo $sharedkey_sumo_prod > ~/.sumo/9e5443dd-3431-4690-9617-31eed61cb55a.sharedkey + echo $SHARED_KEY_SUMO_PROD > ~/.sumo/9e5443dd-3431-4690-9617-31eed61cb55a.sharedkey ls -l ~/.sumo/9e5443dd-3431-4690-9617-31eed61cb55a.sharedkey pytest -s --timeout=300 ./tests/integration diff --git a/backend_py/primary/primary/config.py b/backend_py/primary/primary/config.py index f45b42209..766ea3561 100644 --- a/backend_py/primary/primary/config.py +++ b/backend_py/primary/primary/config.py @@ -17,8 +17,7 @@ SMDA_RESOURCE_SCOPE = os.environ["WEBVIZ_SMDA_RESOURCE_SCOPE"] ENTERPRISE_SUBSCRIPTION_KEY = os.environ["WEBVIZ_ENTERPRISE_SUBSCRIPTION_KEY"] SSDL_RESOURCE_SCOPE = os.environ["WEBVIZ_SSDL_RESOURCE_SCOPE"] -# SUMO_ENV = os.getenv("WEBVIZ_SUMO_ENV", "prod") -SUMO_ENV ="prod" +SUMO_ENV = os.getenv("WEBVIZ_SUMO_ENV", "prod") GRAPH_SCOPES = ["User.Read", "User.ReadBasic.All"] VDS_HOST_ADDRESS = os.environ["WEBVIZ_VDS_HOST_ADDRESS"] diff --git a/backend_py/primary/pyproject.toml b/backend_py/primary/pyproject.toml index be4134ce0..34bca71a4 100644 --- a/backend_py/primary/pyproject.toml +++ b/backend_py/primary/pyproject.toml @@ -66,5 +66,6 @@ disallow_untyped_defs = true pythonpath = ["."] filterwarnings = "ignore::DeprecationWarning:pkg_resources" asyncio_mode="auto" +asyncio_default_fixture_loop_scope="session" diff --git a/backend_py/primary/tests/integration/conftest.py b/backend_py/primary/tests/integration/conftest.py index 3bc3e44f4..ca58bd6ba 100644 --- a/backend_py/primary/tests/integration/conftest.py +++ b/backend_py/primary/tests/integration/conftest.py @@ -2,7 +2,6 @@ from dataclasses import dataclass import pytest -from sumo.wrapper import SumoClient from primary.services.utils.authenticated_user import AuthenticatedUser, AccessTokens @@ -20,12 +19,12 @@ class SumoTestEnsemble: ensemble_name: str -@pytest.fixture(name="sumo_test_ensemble_ahm") -def fixture_sumo_test_ensemble_ahm() -> SumoTestEnsemble: +@pytest.fixture(name="sumo_test_ensemble_prod", scope="session") +def fixture_sumo_test_ensemble_prod() -> SumoTestEnsemble: return SumoTestEnsemble(case_uuid="485041ce-ad72-48a3-ac8c-484c0ed95cf8", ensemble_name="iter-0") -@pytest.fixture(name="test_user") +@pytest.fixture(name="test_user", scope="session") def fixture_test_user(): token = "DUMMY_TOKEN_FOR_TESTING" tokens = AccessTokens(sumo_access_token=token) diff --git a/backend_py/primary/tests/integration/routers/explore/test_explore.py b/backend_py/primary/tests/integration/routers/explore/test_explore.py new file mode 100644 index 000000000..2a3a27e00 --- /dev/null +++ b/backend_py/primary/tests/integration/routers/explore/test_explore.py @@ -0,0 +1,9 @@ +from primary.routers.explore import router, FieldInfo, CaseInfo,EnsembleInfo, EnsembleDetails + + + + +async def test_get_fields(test_user) -> None: + print(dir(router)) + field_list = await router.get_fields(test_user) + assert isinstance(field_list, list[FieldInfo]) diff --git a/backend_py/primary/tests/integration/routers/timeseries/test_get_realizations_vector_data.py b/backend_py/primary/tests/integration/routers/timeseries/test_get_realizations_vector_data.py index 901d581a6..1a9089ab0 100644 --- a/backend_py/primary/tests/integration/routers/timeseries/test_get_realizations_vector_data.py +++ b/backend_py/primary/tests/integration/routers/timeseries/test_get_realizations_vector_data.py @@ -1,8 +1,8 @@ +import pytest import numpy as np from primary.routers.timeseries import router from primary.routers.timeseries import schemas -import pytest @pytest.mark.parametrize( @@ -15,14 +15,14 @@ ], ) async def test_get_realizations_vector_data_dates( - test_user, sumo_test_ensemble_ahm, frequency, date_count, expected_mean -): + test_user, sumo_test_ensemble_prod, frequency, date_count, expected_mean +) -> None: realization_data = await router.get_realizations_vector_data( None, test_user, - sumo_test_ensemble_ahm.case_uuid, - sumo_test_ensemble_ahm.ensemble_name, + sumo_test_ensemble_prod.case_uuid, + sumo_test_ensemble_prod.ensemble_name, "FOPT", frequency, ) @@ -43,14 +43,14 @@ async def test_get_realizations_vector_data_dates( ], ) async def test_get_realizations_vector_data_realizations( - test_user, sumo_test_ensemble_ahm, realizations, real_count, expected_mean -): + test_user, sumo_test_ensemble_prod, realizations, real_count, expected_mean +) -> None: realization_data = await router.get_realizations_vector_data( None, test_user, - sumo_test_ensemble_ahm.case_uuid, - sumo_test_ensemble_ahm.ensemble_name, + sumo_test_ensemble_prod.case_uuid, + sumo_test_ensemble_prod.ensemble_name, "FOPT", schemas.Frequency.YEARLY, realizations, diff --git a/backend_py/primary/tests/integration/routers/timeseries/test_get_vector_list.py b/backend_py/primary/tests/integration/routers/timeseries/test_get_vector_list.py index 1ac920734..14f1b1e61 100644 --- a/backend_py/primary/tests/integration/routers/timeseries/test_get_vector_list.py +++ b/backend_py/primary/tests/integration/routers/timeseries/test_get_vector_list.py @@ -1,16 +1,12 @@ from primary.routers.timeseries import router from primary.routers.timeseries import schemas -from sumo.wrapper import SumoClient -from primary.services.utils.authenticated_user import AuthenticatedUser, AccessTokens -from primary.services.sumo_access.summary_access import SummaryAccess -from fmu.sumo.explorer import Explorer -async def test_get_vector_list(test_user, sumo_test_ensemble_ahm): +async def test_get_vector_list(test_user, sumo_test_ensemble_prod) -> None: vector_list = await router.get_vector_list( - None, test_user, sumo_test_ensemble_ahm.case_uuid, sumo_test_ensemble_ahm.ensemble_name + None, test_user, sumo_test_ensemble_prod.case_uuid, sumo_test_ensemble_prod.ensemble_name ) - + assert len(vector_list) == 786 assert isinstance(vector_list[0], schemas.VectorDescription)