some pre-merge cleanup

This commit is contained in:
Ian McEwen
2026-05-31 14:23:34 -07:00
parent 07172f88f3
commit 02485a88fb
2 changed files with 29 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
"""Meshtastic unit tests for tcp_interface.py"""
import re
from unittest.mock import patch
from unittest.mock import MagicMock, patch
import pytest
@@ -56,6 +56,28 @@ def test_TCPInterface_without_connecting():
assert iface.socket is None
@pytest.mark.unit
def test_TCPInterface_close_shutdowns_socket_before_super_close():
"""Close should unblock socket reads before waiting on StreamInterface.close()."""
iface = TCPInterface(hostname="localhost", noProto=True, connectNow=False)
sock = MagicMock()
iface.socket = sock
call_order = []
with patch.object(TCPInterface, "_socket_shutdown", autospec=True) as mock_shutdown:
with patch(
"meshtastic.stream_interface.StreamInterface.close", autospec=True
) as mock_super_close:
mock_shutdown.side_effect = lambda _self: call_order.append("shutdown")
mock_super_close.side_effect = lambda _self: call_order.append("super_close")
iface.close()
assert call_order == ["shutdown", "super_close"]
sock.close.assert_called_once()
assert iface.socket is None
@pytest.mark.unit
def test_TCPInterface_reconnect():
"""Test that _reconnect correctly reconnects"""