Skip to content

Commit

Permalink
Issue #115 eliminate some warnings from TestCrossBackendSplitting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed Sep 11, 2023
1 parent 5eb7608 commit ab5c315
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 5 additions & 4 deletions tests/partitionedjobs/conftest.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion tests/partitionedjobs/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit ab5c315

Please sign in to comment.