mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-06-11 11:56:18 +00:00
Remove finding IDs from test_standalone_fixes.py
Strip finding IDs (F13, F09, M03, M05, M07, R03, R05) from module docstring, section comments, function names, and docstrings.
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Verification tests for standalone bug fixes and cleanup.
|
Verification tests for standalone bug fixes and cleanup.
|
||||||
Findings: F13, F09, M03, M05, M07, R03, R05.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -18,58 +17,58 @@ from meshcore.meshcore import MeshCore
|
|||||||
pytestmark = pytest.mark.asyncio
|
pytestmark = pytest.mark.asyncio
|
||||||
|
|
||||||
|
|
||||||
# ── F13: req_mma removed ──────────────────────────────────────────────────────
|
# ── req_mma removed ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
def test_f13_req_mma_removed():
|
def test_req_mma_removed():
|
||||||
"""F13: The broken req_mma method should no longer exist on BinaryCommandHandler."""
|
"""The broken req_mma method should no longer exist on BinaryCommandHandler."""
|
||||||
assert not hasattr(BinaryCommandHandler, "req_mma"), \
|
assert not hasattr(BinaryCommandHandler, "req_mma"), \
|
||||||
"req_mma should be removed — it had NameError on undefined start/end"
|
"req_mma should be removed — it had NameError on undefined start/end"
|
||||||
|
|
||||||
|
|
||||||
def test_f13_req_mma_sync_still_exists():
|
def test_req_mma_sync_still_exists():
|
||||||
"""F13: req_mma_sync should still be present and functional."""
|
"""req_mma_sync should still be present and functional."""
|
||||||
assert hasattr(BinaryCommandHandler, "req_mma_sync"), \
|
assert hasattr(BinaryCommandHandler, "req_mma_sync"), \
|
||||||
"req_mma_sync should still exist after removing req_mma"
|
"req_mma_sync should still exist after removing req_mma"
|
||||||
|
|
||||||
|
|
||||||
# ── F09: DEFAULT_TIMEOUT bumped ───────────────────────────────────────────────
|
# ── DEFAULT_TIMEOUT bumped ───────────────────────────────────────────────
|
||||||
|
|
||||||
def test_f09_default_timeout_bumped():
|
def test_default_timeout_bumped():
|
||||||
"""F09: DEFAULT_TIMEOUT should be 15.0, not the old 5.0."""
|
"""DEFAULT_TIMEOUT should be 15.0, not the old 5.0."""
|
||||||
assert CommandHandlerBase.DEFAULT_TIMEOUT == 15.0, \
|
assert CommandHandlerBase.DEFAULT_TIMEOUT == 15.0, \
|
||||||
f"DEFAULT_TIMEOUT is {CommandHandlerBase.DEFAULT_TIMEOUT}, expected 15.0"
|
f"DEFAULT_TIMEOUT is {CommandHandlerBase.DEFAULT_TIMEOUT}, expected 15.0"
|
||||||
|
|
||||||
|
|
||||||
def test_f09_instance_default_timeout():
|
def test_instance_default_timeout():
|
||||||
"""F09: Instance default_timeout should inherit the new 15.0 value."""
|
"""Instance default_timeout should inherit the new 15.0 value."""
|
||||||
handler = CommandHandlerBase()
|
handler = CommandHandlerBase()
|
||||||
assert handler.default_timeout == 15.0
|
assert handler.default_timeout == 15.0
|
||||||
|
|
||||||
|
|
||||||
def test_f09_custom_timeout_still_works():
|
def test_custom_timeout_still_works():
|
||||||
"""F09: Passing a custom timeout should still override the default."""
|
"""Passing a custom timeout should still override the default."""
|
||||||
handler = CommandHandlerBase(default_timeout=30.0)
|
handler = CommandHandlerBase(default_timeout=30.0)
|
||||||
assert handler.default_timeout == 30.0
|
assert handler.default_timeout == 30.0
|
||||||
|
|
||||||
|
|
||||||
# ── M03: set_flood_scope TypeError guard ──────────────────────────────────────
|
# ── set_flood_scope TypeError guard ──────────────────────────────────────
|
||||||
|
|
||||||
async def test_m03_set_flood_scope_bad_type_raises():
|
async def test_set_flood_scope_bad_type_raises():
|
||||||
"""M03: Passing an unsupported type (e.g., int) should raise TypeError."""
|
"""Passing an unsupported type (e.g., int) should raise TypeError."""
|
||||||
handler = MessagingCommands()
|
handler = MessagingCommands()
|
||||||
with pytest.raises(TypeError, match="unsupported scope type"):
|
with pytest.raises(TypeError, match="unsupported scope type"):
|
||||||
await handler.set_flood_scope(42)
|
await handler.set_flood_scope(42)
|
||||||
|
|
||||||
|
|
||||||
async def test_m03_set_flood_scope_bad_type_bytearray():
|
async def test_set_flood_scope_bad_type_bytearray():
|
||||||
"""M03: bytearray is not bytes — should raise TypeError."""
|
"""bytearray is not bytes — should raise TypeError."""
|
||||||
handler = MessagingCommands()
|
handler = MessagingCommands()
|
||||||
with pytest.raises(TypeError, match="unsupported scope type"):
|
with pytest.raises(TypeError, match="unsupported scope type"):
|
||||||
await handler.set_flood_scope(bytearray(b"\x00" * 16))
|
await handler.set_flood_scope(bytearray(b"\x00" * 16))
|
||||||
|
|
||||||
|
|
||||||
async def test_m03_set_flood_scope_none_still_works():
|
async def test_set_flood_scope_none_still_works():
|
||||||
"""M03: None scope should reach send() without TypeError — verifies the None branch still binds scope_key."""
|
"""None scope should reach send() without TypeError — verifies the None branch still binds scope_key."""
|
||||||
handler = MessagingCommands()
|
handler = MessagingCommands()
|
||||||
handler._sender_func = AsyncMock()
|
handler._sender_func = AsyncMock()
|
||||||
handler.dispatcher = EventDispatcher()
|
handler.dispatcher = EventDispatcher()
|
||||||
@@ -86,8 +85,8 @@ async def test_m03_set_flood_scope_none_still_works():
|
|||||||
handler.dispatcher.running = False
|
handler.dispatcher.running = False
|
||||||
|
|
||||||
|
|
||||||
async def test_m03_set_flood_scope_str_still_works():
|
async def test_set_flood_scope_str_still_works():
|
||||||
"""M03: String scope should reach send() without TypeError."""
|
"""String scope should reach send() without TypeError."""
|
||||||
handler = MessagingCommands()
|
handler = MessagingCommands()
|
||||||
handler._sender_func = AsyncMock()
|
handler._sender_func = AsyncMock()
|
||||||
handler.dispatcher = EventDispatcher()
|
handler.dispatcher = EventDispatcher()
|
||||||
@@ -103,8 +102,8 @@ async def test_m03_set_flood_scope_str_still_works():
|
|||||||
handler.dispatcher.running = False
|
handler.dispatcher.running = False
|
||||||
|
|
||||||
|
|
||||||
async def test_m03_set_flood_scope_bytes_still_works():
|
async def test_set_flood_scope_bytes_still_works():
|
||||||
"""M03: Bytes scope should reach send() without TypeError."""
|
"""Bytes scope should reach send() without TypeError."""
|
||||||
handler = MessagingCommands()
|
handler = MessagingCommands()
|
||||||
handler._sender_func = AsyncMock()
|
handler._sender_func = AsyncMock()
|
||||||
handler.dispatcher = EventDispatcher()
|
handler.dispatcher = EventDispatcher()
|
||||||
@@ -120,20 +119,20 @@ async def test_m03_set_flood_scope_bytes_still_works():
|
|||||||
handler.dispatcher.running = False
|
handler.dispatcher.running = False
|
||||||
|
|
||||||
|
|
||||||
# ── M05: dead path_hash_mode shift removed ────────────────────────────────────
|
# ── dead path_hash_mode shift removed ────────────────────────────────────
|
||||||
|
|
||||||
def test_m05_no_shift_in_update_contact():
|
def test_no_shift_in_update_contact():
|
||||||
"""M05: The dead `>> 6` shift on out_path_len should not appear in contact.py."""
|
"""The dead `>> 6` shift on out_path_len should not appear in contact.py."""
|
||||||
import meshcore.commands.contact as contact_mod
|
import meshcore.commands.contact as contact_mod
|
||||||
source = inspect.getsource(contact_mod.ContactCommands.update_contact)
|
source = inspect.getsource(contact_mod.ContactCommands.update_contact)
|
||||||
assert ">> 6" not in source, \
|
assert ">> 6" not in source, \
|
||||||
"Dead path_hash_mode = out_path_len >> 6 shift should be removed"
|
"Dead path_hash_mode = out_path_len >> 6 shift should be removed"
|
||||||
|
|
||||||
|
|
||||||
# ── M07: get_contacts returns Event, never None ───────────────────────────────
|
# ── get_contacts returns Event, never None ───────────────────────────────
|
||||||
|
|
||||||
async def test_m07_get_contacts_timeout_returns_error_event():
|
async def test_get_contacts_timeout_returns_error_event():
|
||||||
"""M07: On timeout (no futures complete), get_contacts should return an Error Event, not None."""
|
"""On timeout (no futures complete), get_contacts should return an Error Event, not None."""
|
||||||
handler = ContactCommands()
|
handler = ContactCommands()
|
||||||
handler._sender_func = AsyncMock()
|
handler._sender_func = AsyncMock()
|
||||||
handler._reader = MagicMock()
|
handler._reader = MagicMock()
|
||||||
@@ -147,10 +146,10 @@ async def test_m07_get_contacts_timeout_returns_error_event():
|
|||||||
assert result.type == EventType.ERROR
|
assert result.type == EventType.ERROR
|
||||||
|
|
||||||
|
|
||||||
# ── R03: binary request pre-registration ──────────────────────────────────────
|
# ── binary request pre-registration ──────────────────────────────────────
|
||||||
|
|
||||||
async def test_r03_placeholder_registered_before_send():
|
async def test_placeholder_registered_before_send():
|
||||||
"""R03: A placeholder binary request should be registered before send() is called."""
|
"""A placeholder binary request should be registered before send() is called."""
|
||||||
from meshcore.packets import BinaryReqType
|
from meshcore.packets import BinaryReqType
|
||||||
|
|
||||||
handler = CommandHandlerBase()
|
handler = CommandHandlerBase()
|
||||||
@@ -198,10 +197,10 @@ async def test_r03_placeholder_registered_before_send():
|
|||||||
"register_binary_request should be called at least once for the placeholder"
|
"register_binary_request should be called at least once for the placeholder"
|
||||||
|
|
||||||
|
|
||||||
# ── R05: MeshCore.subscribe annotation matches EventDispatcher ────────────────
|
# ── MeshCore.subscribe annotation matches EventDispatcher ────────────────
|
||||||
|
|
||||||
def test_r05_subscribe_annotation_matches_dispatcher():
|
def test_subscribe_annotation_matches_dispatcher():
|
||||||
"""R05: MeshCore.subscribe callback annotation should match EventDispatcher.subscribe."""
|
"""MeshCore.subscribe callback annotation should match EventDispatcher.subscribe."""
|
||||||
mc_hints = MeshCore.subscribe.__annotations__
|
mc_hints = MeshCore.subscribe.__annotations__
|
||||||
ed_hints = EventDispatcher.subscribe.__annotations__
|
ed_hints = EventDispatcher.subscribe.__annotations__
|
||||||
|
|
||||||
@@ -216,8 +215,8 @@ def test_r05_subscribe_annotation_matches_dispatcher():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_r05_no_coroutine_import_in_meshcore():
|
def test_no_coroutine_import_in_meshcore():
|
||||||
"""R05: After widening the annotation, Coroutine should no longer be imported in meshcore.py."""
|
"""After widening the annotation, Coroutine should no longer be imported in meshcore.py."""
|
||||||
import meshcore.meshcore as mc_mod
|
import meshcore.meshcore as mc_mod
|
||||||
source = inspect.getsource(mc_mod)
|
source = inspect.getsource(mc_mod)
|
||||||
# Check the import line specifically — Coroutine should not be in the typing imports
|
# Check the import line specifically — Coroutine should not be in the typing imports
|
||||||
|
|||||||
Reference in New Issue
Block a user