Skip to content

Commit

Permalink
Add dark storage test for summary response
Browse files Browse the repository at this point in the history
  • Loading branch information
Yngve S. Kristiansen authored and yngve-sk committed Sep 20, 2024
1 parent ce4149b commit 27648a7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/unit_tests/dark_storage/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ def dark_storage_client(monkeypatch):
yield client


@pytest.fixture
def dark_storage_client_snake_oil(monkeypatch):
with dark_storage_app_(monkeypatch) as dark_app:
monkeypatch.setenv("ERT_STORAGE_ENS_PATH", "storage/snake_oil/ensemble")
with TestClient(dark_app) as client:
yield client


@pytest.fixture
def env(monkeypatch):
monkeypatch.setenv("ERT_STORAGE_NO_TOKEN", "yup")
Expand Down
32 changes: 32 additions & 0 deletions tests/unit_tests/dark_storage/test_http_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,38 @@ def test_get_response(poly_example_tmp_dir, dark_storage_client):
assert len(record_df1.index) == 3


@pytest.mark.integration_test
def test_get_summary_response(
copy_snake_oil_case_storage, dark_storage_client_snake_oil
):
resp: Response = dark_storage_client_snake_oil.get("/experiments")
experiment_json = resp.json()

assert len(experiment_json) == 1

# ensemble_experiment, so only 1 ensemble
assert len(experiment_json[0]["ensemble_ids"]) == 1

ensemble_id = experiment_json[0]["ensemble_ids"][0]

resp_ensemble: Response = dark_storage_client_snake_oil.get(
f"/ensembles/{ensemble_id}"
).json()
userdata = resp_ensemble["userdata"]

assert resp_ensemble["size"] == 5
assert userdata == {"name": "default_0", "experiment_name": "ensemble-experiment"}

resp_response: Response = dark_storage_client_snake_oil.get(
f"/ensembles/{ensemble_id}/records/FOPR",
headers={"accept": "text/csv"},
)
stream = io.BytesIO(resp_response.content)
record_df = pd.read_csv(stream, index_col=0, float_precision="round_trip")
assert len(record_df.columns) == 200
assert len(record_df.index) == 5


@pytest.mark.integration_test
def test_get_ensemble_parameters(poly_example_tmp_dir, dark_storage_client):
resp: Response = dark_storage_client.get("/experiments")
Expand Down

0 comments on commit 27648a7

Please sign in to comment.