fix(sfm): a different UM serial at a held address is refused (409), not swapped

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-10-21 01:45:17 -04:00
1 parent aa79e996c5
commit d393a149f8
2 files changed
+18 -3

No files matched your search

+5 -1
View File
@@ -121,7 +121,11 @@ class DeviceAccess:
with self._sessions_guard:
session = self._sessions.get(address.key)
if session is not None and session.serial != serial:
session.hang_up()
if session.is_open:
raise WrongUnit(
f"a Series-4 line to {session.serial} is held at {address.key}; "
f"{serial} cannot be reached there -- POST /device/hangup first "
"if the modem has moved")
session = None
if session is None:
session = Series4Session(address, serial, self._s4_factory, clock=self._clock)
+13 -2
View File
@@ -79,12 +79,23 @@ def test_a_dropped_line_is_called_up_again_quietly():
assert st.series == 4 and second.opened == 1
def test_a_different_serial_at_the_same_address_hangs_up_the_old_line():
def test_a_different_serial_at_a_held_address_is_refused_without_io():
first, second = FakeMicromateClient(), FakeMicromateClient(serial="UM12947")
da = access(s4=[first, second])
da.status(ADDR, "UM20147")
with pytest.raises(WrongUnit, match="hangup"):
da.status(ADDR, "UM12947")
assert first.closed == 0 and second.opened == 0
assert da.held_serial(ADDR) == "UM20147"
def test_a_different_serial_replaces_a_session_that_is_no_longer_open():
first, second = FakeMicromateClient(), FakeMicromateClient(serial="UM12947")
da = access(s4=[first, second])
da.status(ADDR, "UM20147")
first.close()
da.status(ADDR, "UM12947")
assert first.closed == 1 and second.opened == 1
assert second.opened == 1
def test_a_busy_unit_answers_423_without_a_second_connection():