fix(k1): stabilize repeated acquisition and live viewer recovery

This commit is contained in:
DCCONSTRUCTIONS
2026-07-29 01:55:12 +03:00
parent 37b8930527
commit 2a97cf28c0
28 changed files with 2776 additions and 286 deletions
+33
View File
@@ -778,3 +778,36 @@ def test_post_publish_timeout_poisoned_transport_never_retries() -> None:
required_response_operation_keys={"bootstrap:1:DeviceInfoRequest"},
)
assert len(fake.publish_calls) == 1
def test_network_loop_failure_keeps_exact_paho_result_and_phase() -> None:
class LoopFailureClient(FakeControlClient):
def loop(self, timeout: float) -> mqtt.MQTTErrorCode:
if self.publish_calls and not self.events:
return mqtt.MQTT_ERR_CONN_LOST
return super().loop(timeout)
fake = LoopFailureClient()
transport = ReviewedApplicationMqttTransport(
"192.168.1.20",
client_factory=lambda: cast(mqtt.Client, fake),
)
transport.open()
with pytest.raises(
ApplicationCommandOutcomeUnknown,
match=r"phase=post-publish-drain, result=7: The connection was lost",
):
transport.exchange_batch_once(
[_envelope()],
required_response_operation_keys={"bootstrap:1:DeviceInfoRequest"},
)
snapshot = transport.snapshot().as_dict()
assert snapshot["state"] == "poisoned"
assert snapshot["last_loop_result_code"] == int(mqtt.MQTT_ERR_CONN_LOST)
assert snapshot["last_loop_result_name"] == mqtt.error_string(
int(mqtt.MQTT_ERR_CONN_LOST)
)
assert snapshot["last_loop_phase"] == "post-publish-drain"
assert len(fake.publish_calls) == 1