From 1ac2b63ac8123bce3797d6ae52f4b66ffb1f0002 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Tue, 21 Feb 2023 10:07:48 -0700 Subject: [PATCH] feat, tests: add fixtures for prebuilt catalogs I don't love the name "prebuilt" but I can't think of a better one. --- tests/conftest.py | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index b4563f17f..fe46fe172 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,10 +1,11 @@ from datetime import datetime import pytest +from pytest import FixtureRequest from pystac import Catalog, Collection, Item -from .utils import ARBITRARY_BBOX, ARBITRARY_EXTENT, ARBITRARY_GEOM +from .utils import ARBITRARY_BBOX, ARBITRARY_EXTENT, ARBITRARY_GEOM, TestCases @pytest.fixture @@ -12,6 +13,44 @@ def catalog() -> Catalog: return Catalog("test-catalog", "A test catalog") +@pytest.fixture +def prebuilt_catalog_1() -> Catalog: + path = TestCases.get_path("data-files/catalogs/test-case-1/catalog.json") + return Catalog.from_file(path) + + +@pytest.fixture +def prebuilt_catalog_2() -> Catalog: + path = TestCases.get_path("data-files/catalogs/test-case-2/catalog.json") + return Catalog.from_file(path) + + +@pytest.fixture +def prebuilt_catalog_4() -> Catalog: + path = TestCases.get_path("data-files/catalogs/test-case-4/catalog.json") + return Catalog.from_file(path) + + +@pytest.fixture +def prebuilt_catalog_5() -> Catalog: + path = TestCases.get_path("data-files/catalogs/test-case-5/catalog.json") + return Catalog.from_file(path) + + +@pytest.fixture +def prebuilt_catalog_6() -> Catalog: + path = TestCases.get_path("data-files/catalogs/test-case-6/catalog.json") + return Catalog.from_file(path) + + +@pytest.fixture(params=["1", "2", "4", "5", "6"]) +def prebuilt_catalog(request: FixtureRequest) -> Catalog: + path = TestCases.get_path( + f"data-files/catalogs/test-case-{request.param}/catalog.json" + ) + return Catalog.from_file(path) + + @pytest.fixture def collection() -> Catalog: return Collection("test-collection", "A test collection", ARBITRARY_EXTENT)