From 4459069692302001382695d7882d56d77f41d888 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt <13055656+schmidtnz@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:21:27 +1300 Subject: [PATCH] refactor: randomize fake linz slug and deduplicate code --- scripts/conftest.py | 12 ++++++++++++ scripts/stac/imagery/tests/conftest.py | 5 ----- scripts/tests/conftest.py | 6 ------ 3 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 scripts/conftest.py delete mode 100644 scripts/tests/conftest.py diff --git a/scripts/conftest.py b/scripts/conftest.py new file mode 100644 index 00000000..e5e044b1 --- /dev/null +++ b/scripts/conftest.py @@ -0,0 +1,12 @@ +import pytest +from random import choice, randint +from string import ascii_lowercase + +@pytest.fixture +def fake_linz_slug() -> str: + random_string = "".join(choice(ascii_lowercase) for _ in range(6)) + start_year = randint(2000,2009) + end_year = randint(2010,2019) + gsd = choice([0.75, 0.3, 1, 0.075]) + + return f"a-random-slug-{random_string}_{start_year}-{end_year}_{gsd}m" diff --git a/scripts/stac/imagery/tests/conftest.py b/scripts/stac/imagery/tests/conftest.py index 775dfd08..0860b2d5 100644 --- a/scripts/stac/imagery/tests/conftest.py +++ b/scripts/stac/imagery/tests/conftest.py @@ -21,8 +21,3 @@ def fake_collection_metadata() -> Iterator[CollectionMetadata]: "geographic_description": None, } yield collection_metadata - - -@pytest.fixture -def fake_linz_slug() -> str: - return "somewhere-in-new-zealand_2021-2023_0.75m" diff --git a/scripts/tests/conftest.py b/scripts/tests/conftest.py deleted file mode 100644 index ee254026..00000000 --- a/scripts/tests/conftest.py +++ /dev/null @@ -1,6 +0,0 @@ -import pytest - - -@pytest.fixture -def fake_linz_slug() -> str: - return "somewhere-in-new-zealand_2021-2023_0.75m"