57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
"""Production smoke must reject incomplete restored photo dependencies."""
|
|||
|
|
|
||
|
|
import io
|
||
|
|
import json
|
||
|
|
import runpy
|
||
|
|
from pathlib import Path
|
||
|
|
from urllib.request import Request
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.parametrize(
|
||
|
|
"sources,connection,passes",
|
||
|
|
[
|
||
|
|
([], {}, True),
|
||
|
|
([{"enabled": False, "people_filter": True}], {}, True),
|
||
|
|
(
|
||
|
|
[{"enabled": True, "people_filter": True}],
|
||
|
|
{"configured": False, "connected": False},
|
||
|
|
False,
|
||
|
|
),
|
||
|
|
(
|
||
|
|
[{"enabled": True, "people_filter": True}],
|
||
|
|
{"configured": True, "connected": False},
|
||
|
|
False,
|
||
|
|
),
|
||
|
|
(
|
||
|
|
[{"enabled": True, "people_filter": True}],
|
||
|
|
{"configured": True, "connected": True},
|
||
|
|
True,
|
||
|
|
),
|
||
|
|
],
|
||
|
|
)
|
||
|
|
def test_smoke_validates_people_filter_dependency(
|
||
|
|
monkeypatch, sources, connection, passes
|
||
|
|
):
|
||
|
|
calls = []
|
||
|
|
|
||
|
|
class Response(io.BytesIO):
|
||
|
|
status = 200
|
||
|
|
|
||
|
|
def read_only(request: Request, timeout):
|
||
|
|
assert request.get_method() == "GET"
|
||
|
|
calls.append(request.full_url)
|
||
|
|
value = sources if request.full_url.endswith("/photo-sources") else connection
|
||
|
|
return Response(json.dumps(value).encode())
|
||
|
|
|
||
|
|
monkeypatch.setenv("FRAME_FLOW_TOKEN", "fixture")
|
||
|
|
monkeypatch.setattr("urllib.request.urlopen", read_only)
|
||
|
|
script = Path(__file__).parents[1] / "scripts/smoke-test.py"
|
||
|
|
if passes:
|
||
|
|
runpy.run_path(str(script))
|
||
|
|
else:
|
||
|
|
with pytest.raises(RuntimeError, match="requires Photos connection"):
|
||
|
|
runpy.run_path(str(script))
|
||
|
|
assert len(calls) >= 10
|