Remove finding IDs from test_connection_manager.py

Strip internal forensics finding references (F01, F02, F03, N11)
from docstrings and section comments. The descriptive text is
preserved — only the ID prefixes are removed.
This commit is contained in:
Matthew Wolter
2026-04-12 07:54:02 -07:00
parent 9e2fc0d63e
commit f3aa131019

View File

@@ -1,4 +1,4 @@
"""Tests for reconnect-path fixes (F01, F02, F03, N11).""" """Tests for reconnect-path fixes."""
import asyncio import asyncio
@@ -69,15 +69,15 @@ class _EventCollector:
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# F01 — TCP connect() should return a plain value, not an asyncio.Future # TCP connect() should return a plain value, not an asyncio.Future
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_tcp_connect_returns_plain_string(): async def test_tcp_connect_returns_plain_string():
"""F01: After the fix, TCPConnection.connect() returns self.host (a """TCPConnection.connect() returns self.host (a plain string), not an
plain string), not an asyncio.Future. We test indirectly via asyncio.Future. We test indirectly via ConnectionManager — the
ConnectionManager — the CONNECTED event payload should contain a plain CONNECTED event payload should contain a plain string, not a Future
string, not a Future object.""" object."""
conn = FakeConnection(connect_results=["10.0.0.1"]) conn = FakeConnection(connect_results=["10.0.0.1"])
dispatcher = EventDispatcher() dispatcher = EventDispatcher()
await dispatcher.start() await dispatcher.start()
@@ -101,12 +101,12 @@ async def test_tcp_connect_returns_plain_string():
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# F03 — Reconnect attempts must not compound (no tail-recursive create_task) # Reconnect attempts must not compound (no tail-recursive create_task)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_reconnect_loop_does_not_compound(): async def test_reconnect_loop_does_not_compound():
"""F03: _attempt_reconnect must use a single iterative loop. After """_attempt_reconnect must use a single iterative loop. After
max_reconnect_attempts failures, exactly that many connect() calls max_reconnect_attempts failures, exactly that many connect() calls
should have been made — no exponential fan-out from orphaned tasks.""" should have been made — no exponential fan-out from orphaned tasks."""
# All attempts fail (return None) # All attempts fail (return None)
@@ -140,7 +140,7 @@ async def test_reconnect_loop_does_not_compound():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_disconnect_cancels_reconnect_loop(): async def test_disconnect_cancels_reconnect_loop():
"""F03: disconnect() during an active reconnect loop must cancel the """disconnect() during an active reconnect loop must cancel the
single task cleanly — no orphaned tasks left running.""" single task cleanly — no orphaned tasks left running."""
# Simulate a connection that always fails (returns None), giving us # Simulate a connection that always fails (returns None), giving us
# time to call disconnect() mid-loop. # time to call disconnect() mid-loop.
@@ -173,12 +173,12 @@ async def test_disconnect_cancels_reconnect_loop():
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# F02 — reconnect_callback (send_appstart) is called after reconnect # reconnect_callback (send_appstart) is called after reconnect
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_reconnect_callback_called_after_reconnect(): async def test_reconnect_callback_called_after_reconnect():
"""F02: When ConnectionManager reconnects successfully, the """When ConnectionManager reconnects successfully, the
reconnect_callback (e.g. send_appstart) must be invoked.""" reconnect_callback (e.g. send_appstart) must be invoked."""
callback_called = [] callback_called = []
@@ -209,8 +209,8 @@ async def test_reconnect_callback_called_after_reconnect():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_reconnect_callback_failure_does_not_crash_loop(): async def test_reconnect_callback_failure_does_not_crash_loop():
"""F02: If the reconnect_callback raises, the reconnect still counts """If the reconnect_callback raises, the reconnect still counts as
as successful (transport is up) — the callback failure is logged but successful (transport is up) — the callback failure is logged but
does not crash the loop or leave the manager in a broken state.""" does not crash the loop or leave the manager in a broken state."""
async def failing_callback(): async def failing_callback():
raise RuntimeError("appstart failed") raise RuntimeError("appstart failed")
@@ -243,12 +243,12 @@ async def test_reconnect_callback_failure_does_not_crash_loop():
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# N11 — connect() returning None is a soft failure (BLE scan miss) # connect() returning None is a soft failure (BLE scan miss)
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_connect_none_is_soft_failure(): async def test_connect_none_is_soft_failure():
"""N11: When connect() returns None (e.g. BLE scan found no device), """When connect() returns None (e.g. BLE scan found no device),
ConnectionManager.connect() should NOT set _is_connected and should ConnectionManager.connect() should NOT set _is_connected and should
NOT emit a CONNECTED event.""" NOT emit a CONNECTED event."""
conn = FakeConnection(connect_results=[None]) conn = FakeConnection(connect_results=[None])
@@ -271,8 +271,8 @@ async def test_connect_none_is_soft_failure():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_no_reconnect_callback_is_noop(): async def test_no_reconnect_callback_is_noop():
"""N11/F02: When no reconnect_callback is provided (backwards compat """When no reconnect_callback is provided (backwards compat for
for direct ConnectionManager users), reconnect should still work.""" direct ConnectionManager users), reconnect should still work."""
conn = FakeConnection(connect_results=["10.0.0.1"]) conn = FakeConnection(connect_results=["10.0.0.1"])
dispatcher = EventDispatcher() dispatcher = EventDispatcher()
await dispatcher.start() await dispatcher.start()