mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-24 09:55:12 +00:00
test: install the EXAMPLE service through a fixture, not the live config
Two tests failed when the local unshackle.yaml left out the in-repo services folder.
This commit is contained in:
@@ -69,6 +69,17 @@ def no_speed_limit(monkeypatch: pytest.MonkeyPatch) -> None:
|
|||||||
monkeypatch.setattr(requests_downloader, "speed_limit_locked", False)
|
monkeypatch.setattr(requests_downloader, "speed_limit_locked", False)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def example_service(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
|
"""Make the in-repo EXAMPLE the only installed service, whatever the local unshackle.yaml lists."""
|
||||||
|
from unshackle.core import services
|
||||||
|
|
||||||
|
path = config.directories.namespace_dir / "services" / "EXAMPLE" / "__init__.py"
|
||||||
|
monkeypatch.setattr(services, "SERVICES", [path])
|
||||||
|
monkeypatch.setattr(services, "MODULES", {})
|
||||||
|
monkeypatch.setattr(services, "LOAD_ERRORS", [])
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mux_args(monkeypatch: pytest.MonkeyPatch) -> Callable[..., list[str]]:
|
def mux_args(monkeypatch: pytest.MonkeyPatch) -> Callable[..., list[str]]:
|
||||||
"""Run Tracks.mux up to mkvmerge and return its arguments; ``ids`` is what the track ID probe reports."""
|
"""Run Tracks.mux up to mkvmerge and return its arguments; ``ids`` is what the track ID probe reports."""
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ def test_region_mismatch_raises(monkeypatch):
|
|||||||
assert exc_info.value.details == {"service": "EXAMPLE"}
|
assert exc_info.value.details == {"service": "EXAMPLE"}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("example_service")
|
||||||
def test_geoblocked_client_region_raises(monkeypatch):
|
def test_geoblocked_client_region_raises(monkeypatch):
|
||||||
patch_server_region(monkeypatch, "CA")
|
patch_server_region(monkeypatch, "CA")
|
||||||
service_class = handlers.Services.load("EXAMPLE")
|
service_class = handlers.Services.load("EXAMPLE")
|
||||||
|
|||||||
@@ -232,6 +232,7 @@ async def test_heartbeat_late_error_counts_as_rejected(aiohttp_client, monkeypat
|
|||||||
assert stats.errors == {"-": {"SERVICE_ERROR": 1}}
|
assert stats.errors == {"-": {"SERVICE_ERROR": 1}}
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("example_service")
|
||||||
@pytest.mark.parametrize(("service", "counted_as"), [("EXAMPLE", "EXAMPLE"), ("NOT_INSTALLED", "-")])
|
@pytest.mark.parametrize(("service", "counted_as"), [("EXAMPLE", "EXAMPLE"), ("NOT_INSTALLED", "-")])
|
||||||
async def test_error_is_counted_by_service_and_logged_with_its_ref(
|
async def test_error_is_counted_by_service_and_logged_with_its_ref(
|
||||||
aiohttp_client, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, service: str, counted_as: str
|
aiohttp_client, monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, service: str, counted_as: str
|
||||||
|
|||||||
Reference in New Issue
Block a user