Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dark storage test for summary response #8745

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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