diff --git a/tests/partitionedjobs/conftest.py b/tests/partitionedjobs/conftest.py index 3911ce96..b7992ec1 100644 --- a/tests/partitionedjobs/conftest.py +++ b/tests/partitionedjobs/conftest.py @@ -1,6 +1,6 @@ import collections import re -from typing import Dict, List, Tuple +from typing import Dict, Iterable, List, Tuple import pytest import requests @@ -81,10 +81,11 @@ def get_job_data(self, user_id, job_id) -> DummyBatchJobData: raise JobNotFoundException(job_id=job_id) return self.jobs[user_id, job_id] - def setup_basic_requests_mocks(self): + def setup_basic_requests_mocks(self, collections: Iterable[str] = ("S2",)): # Basic collections - self.requests_mock.get(self.backend_url + "/collections", json={"collections": [{"id": "S2"}]}) - self.requests_mock.get(self.backend_url + "/collections/S2", json={"id": "S2"}) + for cid in collections: + self.requests_mock.get(self.backend_url + "/collections", json={"collections": [{"id": cid}]}) + self.requests_mock.get(self.backend_url + f"/collections/{cid}", json={"id": cid}) # Batch job handling: list jobs self.requests_mock.get(self.backend_url + "/jobs", json=self._handle_get_jobs) # Batch job handling: create job diff --git a/tests/partitionedjobs/test_api.py b/tests/partitionedjobs/test_api.py index 64f949c6..dfc8b941 100644 --- a/tests/partitionedjobs/test_api.py +++ b/tests/partitionedjobs/test_api.py @@ -44,13 +44,22 @@ def __init__(self, date: str): @pytest.fixture def dummy1(backend1, requests_mock) -> DummyBackend: - # TODO: rename this fixture to dummy_backed1 + # TODO: rename this fixture to dummy_backed1 for clarity dummy = DummyBackend(requests_mock=requests_mock, backend_url=backend1, job_id_template="1-jb-{i}") dummy.setup_basic_requests_mocks() dummy.register_user(bearer_token=TEST_USER_BEARER_TOKEN, user_id=TEST_USER) return dummy +@pytest.fixture +def dummy2(backend2, requests_mock) -> DummyBackend: + # TODO: rename this fixture to dummy_backed2 for clarity + dummy = DummyBackend(requests_mock=requests_mock, backend_url=backend2, job_id_template="2-jb-{i}") + dummy.setup_basic_requests_mocks(collections=["S22"]) + dummy.register_user(bearer_token=TEST_USER_BEARER_TOKEN, user_id=TEST_USER) + return dummy + + class TestFlimsyBatchJobSplitting: now = _Now("2022-01-19T12:34:56Z") @@ -613,6 +622,7 @@ def test_job_results_basic(self, flask_app, api100, dummy1): # TODO: more/full TileGridSplitter batch job tests +@pytest.mark.usefixtures("dummy1", "dummy2") class TestCrossBackendSplitting: now = _Now("2022-01-19T12:34:56Z")