fix(sfm): retry once on a dropped held line; refuse Series-3 beside a held Series-4 line
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
1 parent
96c7b31f4e
commit
73b6089012
2 files changed
+67
-7
No files matched your search
@@ -13,7 +13,10 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from device_access_fakes import FakeMiniMateClient, FakeMicromateClient # noqa: E402
|
||||
from sfm.device_access.access import DeviceAccess # noqa: E402
|
||||
from sfm.device_access.errors import BadRequest, CallHomeInProgress, UnitBusy # noqa: E402
|
||||
import micromate.protocol as mm_proto # noqa: E402
|
||||
from sfm.device_access.errors import ( # noqa: E402
|
||||
BadRequest, CallHomeInProgress, ConnectFailed, UnitBusy, WrongUnit,
|
||||
)
|
||||
from sfm.device_access.models import UnitAddress # noqa: E402
|
||||
from sfm.device_access.s4 import RingDetected # noqa: E402
|
||||
|
||||
@@ -115,6 +118,40 @@ def test_hang_up_closes_a_held_line():
|
||||
assert da.hang_up(ADDR) is False # nothing left to hang up
|
||||
|
||||
|
||||
def test_a_peer_dropped_line_that_still_reads_open_is_retried_once():
|
||||
first, second = FakeMicromateClient(), FakeMicromateClient()
|
||||
da = access(s4=[first, second])
|
||||
da.status(ADDR, "UM20147")
|
||||
first.fail = [mm_proto.TimeoutError("quiet")] # _open untouched: looks open
|
||||
st = da.status(ADDR, "UM20147")
|
||||
assert st.series == 4 and first.closed == 1 and second.opened == 1
|
||||
|
||||
|
||||
def test_a_failed_fresh_call_up_is_not_retried():
|
||||
da = access(s4=[FakeMicromateClient(open_error=ConnectionRefusedError("no"))])
|
||||
with pytest.raises(ConnectFailed):
|
||||
da.status(ADDR, "UM20147") # a 2nd attempt would pop an empty queue
|
||||
|
||||
|
||||
def test_a_ring_on_a_held_line_is_not_retried():
|
||||
first, second = FakeMicromateClient(), FakeMicromateClient()
|
||||
da = access(s4=[first, second])
|
||||
da.status(ADDR, "UM20147")
|
||||
first.fail = [RingDetected("RADIO RING")]
|
||||
with pytest.raises(CallHomeInProgress):
|
||||
da.status(ADDR, "UM20147")
|
||||
assert second.opened == 0
|
||||
|
||||
|
||||
def test_series3_beside_a_held_series4_line_is_refused_without_io():
|
||||
micro, mini = FakeMicromateClient(), FakeMiniMateClient()
|
||||
da = access(s3=[mini], s4=[micro])
|
||||
da.status(ADDR, "UM20147")
|
||||
with pytest.raises(WrongUnit):
|
||||
da.status(ADDR, "BE18193")
|
||||
assert mini.opened == 0 and micro.closed == 0 and micro.is_open()
|
||||
|
||||
|
||||
# ── the reaper ────────────────────────────────────────────────────────────────
|
||||
|
||||
def test_tick_listens_then_keeps_alive_then_hangs_up_when_idle():
|
||||
|
||||
Reference in new issue
Block a user