You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Chameleon/integration/ptz17_focus_zoom/test_reference_replay.py

31 lines
1.2 KiB
Python

from pathlib import Path
import json
import pytest
from replay_ptz17_reference import LensSample, first_hfov_change, replay
@pytest.mark.parametrize("key,start,request_id,confirmation,delay", [
("1412", 6.115, 3, 10.627, 4.512),
("1424", 8.118, 3, 17.020, 8.902),
("1428", 4.294, 5, 16.985, 12.691),
])
def test_replays_observed_first_optics(
key: str, start: float, request_id: int, confirmation: float, delay: float,
) -> None:
fixture = json.loads(Path(__file__).with_name("reference_fixture.json").read_bytes())
result = replay(fixture[key])
assert result["first_start_s"] == start
assert result["first_confirmed_request"] == request_id
assert result["first_optics_s"] == confirmation and result["startup_to_optics_s"] == delay
assert all(row["first_status_narrowing"] is None for row in result["requests"][:request_id - 1])
assert result["requests"][request_id - 1]["first_status_narrowing"]["hfov_deg"] == pytest.approx(54.122, abs=.001)
def test_measurement_does_not_cross_request_boundary() -> None:
assert first_hfov_change(
LensSample(1., 59.), [LensSample(1.1, float("nan")), LensSample(1.2, 58.9), LensSample(1.3, 54.)],
from_s=1.1, until_s=1.3,
) is None