-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37ad8b1
commit cafa085
Showing
4 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/ert/unit_tests/dark_storage/test_dark_storage_state.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import os | ||
from uuid import UUID | ||
|
||
import pytest | ||
from hypothesis import note, settings | ||
from hypothesis.stateful import rule | ||
from starlette.testclient import TestClient | ||
|
||
from ert.dark_storage.app import app | ||
from ert.dark_storage.enkf import update_storage | ||
from tests.ert.unit_tests.storage.test_local_storage import StatefulStorageTest | ||
|
||
|
||
@settings(max_examples=100) | ||
class DarkStorageStateTest(StatefulStorageTest): | ||
def __init__(self): | ||
super().__init__() | ||
self.prev_no_token = os.environ.get("ERT_STORAGE_NO_TOKEN") | ||
self.prev_ens_path = os.environ.get("ERT_STORAGE_ENS_PATH") | ||
os.environ["ERT_STORAGE_NO_TOKEN"] = "yup" | ||
os.environ["ERT_STORAGE_ENS_PATH"] = str(self.storage.path) | ||
update_storage() | ||
self.client = TestClient(app) | ||
|
||
@rule() | ||
def get_experiment_through_client(self): | ||
self.client.get("/updates/storage") | ||
response = self.client.get("/experiments") | ||
experiment_records = response.json() | ||
note(str((experiment_records, list(self.storage.experiments)))) | ||
assert len(experiment_records) == len(list(self.storage.experiments)) | ||
for record in experiment_records: | ||
storage_experiment = self.storage.get_experiment(UUID(record["id"])) | ||
assert {UUID(i) for i in record["ensemble_ids"]} == { | ||
ens.id for ens in storage_experiment.ensembles | ||
} | ||
|
||
def teardown(self): | ||
super().teardown() | ||
if self.prev_no_token is not None: | ||
os.environ["ERT_STORAGE_NO_TOKEN"] = self.prev_no_token | ||
else: | ||
del os.environ["ERT_STORAGE_NO_TOKEN"] | ||
if self.prev_ens_path is not None: | ||
os.environ["ERT_STORAGE_ENS_PATH"] = self.prev_ens_path | ||
else: | ||
del os.environ["ERT_STORAGE_ENS_PATH"] | ||
|
||
|
||
TestDarkStorage = pytest.mark.integration_test(DarkStorageStateTest.TestCase) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters