chore(k1): checkpoint connection recovery work
This commit is contained in:
@@ -675,20 +675,6 @@ class FakeInteractiveControlSession:
|
||||
self.state_revision += 1
|
||||
return self.snapshot()
|
||||
|
||||
def release_inspection_for_operator_dialogue(
|
||||
self,
|
||||
*,
|
||||
expected_session_generation: int,
|
||||
expected_state_revision: int,
|
||||
) -> dict[str, object]:
|
||||
self._accept_checkpoint(
|
||||
expected_session_generation=expected_session_generation,
|
||||
expected_state_revision=expected_state_revision,
|
||||
)
|
||||
assert self.state == "connection-ready"
|
||||
self.inspection_promotion_allowed = True
|
||||
return self.snapshot()
|
||||
|
||||
def adopt_reconciled_scanning(
|
||||
self,
|
||||
*,
|
||||
@@ -6553,6 +6539,64 @@ def test_control_session_reuses_reachable_process_owned_connection_lease(
|
||||
service._release_application_control_process_lease() # noqa: SLF001
|
||||
|
||||
|
||||
def test_operator_control_open_replaces_verify_inspection_with_fresh_dialogue(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
service, _ = service_with_fake_runtime(tmp_path)
|
||||
transitions: list[str] = []
|
||||
|
||||
class RecordingControlSession(FakeInteractiveControlSession):
|
||||
def close_prestart(self, **kwargs: object) -> dict[str, object]:
|
||||
transitions.append("inspection-closed")
|
||||
return super().close_prestart(**kwargs)
|
||||
|
||||
def retire_for_network_change(self, **kwargs: object) -> dict[str, object]:
|
||||
transitions.append("inspection-retired")
|
||||
return super().retire_for_network_change(**kwargs)
|
||||
|
||||
def open(self, *, inspection_only: bool = False, **kwargs: object) -> dict[str, object]:
|
||||
transitions.append(
|
||||
"inspection-opened" if inspection_only else "canonical-opened"
|
||||
)
|
||||
self.session_generation += 1
|
||||
return super().open(inspection_only=inspection_only, **kwargs)
|
||||
|
||||
control = RecordingControlSession(initial_state="connection-ready")
|
||||
control.session_generation = 7
|
||||
control.state_revision = 11
|
||||
control.inspection_only = True
|
||||
control.inspection_promotion_allowed = False
|
||||
service._application_control_session = control # type: ignore[assignment] # noqa: SLF001
|
||||
binding = _seed_supervised_connection(service)
|
||||
control.verified_control = _verified_control_for_binding(binding)
|
||||
service._acquire_application_control_process_lease() # noqa: SLF001
|
||||
|
||||
monkeypatch.setattr(facade_module, "_control_endpoint_reachable", lambda _target: True)
|
||||
monkeypatch.setattr(facade_module, "_inspect_host_path", _direct_host_path)
|
||||
|
||||
state = service.open_application_control_session(
|
||||
OpenApplicationControlSessionRequest(
|
||||
operator_present=True,
|
||||
owner_controlled_device=True,
|
||||
lixelgo_closed=True,
|
||||
battery_storage_confirmed=True,
|
||||
expected_physical_state_confirmed=True,
|
||||
timezone_name="Europe/Moscow",
|
||||
)
|
||||
)
|
||||
|
||||
assert transitions == [
|
||||
"inspection-closed",
|
||||
"inspection-retired",
|
||||
"canonical-opened",
|
||||
]
|
||||
assert state["application_control_session"]["state"] == "connection-ready"
|
||||
assert state["application_control_session"]["inspection_only"] is False
|
||||
assert state["application_control_session"]["session_generation"] == 8
|
||||
service._release_application_control_process_lease() # noqa: SLF001
|
||||
|
||||
|
||||
def test_reachable_connection_lease_supports_repeated_independent_control_sessions(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
@@ -27705,7 +27749,7 @@ def test_reset_retired_apply_continuation_settles_without_receiver_rehydrate(
|
||||
else:
|
||||
assert control["state"] == "connection-ready"
|
||||
assert control["inspection_only"] is True
|
||||
assert control["inspection_promotion_allowed"] is True
|
||||
assert control["inspection_promotion_allowed"] is False
|
||||
assert settled["connection_attempt"]["safe_next_action"] == (
|
||||
"start-acquisition"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user