From c4ba44ceab120833293184865068b3cdfc6b28e3 Mon Sep 17 00:00:00 2001 From: simonvadee Date: Fri, 15 Oct 2021 14:46:41 +0200 Subject: [PATCH] fix(e2e): destroy_mimic_mapping as fixture --- tests/e2e/conftest.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/e2e/conftest.py b/tests/e2e/conftest.py index b9fece1c0..6dde567d2 100644 --- a/tests/e2e/conftest.py +++ b/tests/e2e/conftest.py @@ -14,15 +14,16 @@ DATA_FIXTURES_DIR = Path(__file__).resolve().parent.parent / "fixtures" -def destroy_source(source): +@pytest.fixture(scope="session") +def destroy_mimic_source(mimic_mapping): """Removes source from river-api if exists""" response = requests.get(f"{settings.RIVER_API_URL}/sources/") for existing_source in response.json(): - if existing_source["name"] == source["name"]: - response = requests.delete(f"{settings.RIVER_API_URL}/sources/{source['id']}/") + if existing_source["name"] == mimic_mapping["name"]: + response = requests.delete(f"{settings.RIVER_API_URL}/sources/{existing_source['id']}/") assert ( response.status_code == 204 - ), f"api DELETE /sources/{source['id']}/ returned an error: {response.text}" + ), f"api DELETE /sources/{existing_source['id']}/ returned an error: {response.text}" @pytest.fixture(scope="session") @@ -51,7 +52,7 @@ def mimic_mapping(): @pytest.fixture(scope="session") -def uploaded_mapping(mimic_mapping): +def uploaded_mapping(mimic_mapping, destroy_mimic_source): """Impots the mimic mapping to river-api Args: @@ -63,7 +64,6 @@ def uploaded_mapping(mimic_mapping): Yields: dict: The uploaded mapping """ - destroy_source(mimic_mapping) try: # send a batch request response = requests.post(f"{settings.RIVER_API_URL}/sources/import/", json=mimic_mapping)