Refactor radar system

This commit is contained in:
Ayzen
2026-10-05 16:46:28 +03:00
parent 515049d2ed
commit 8f097dfa2e
179 changed files with 8212 additions and 6676 deletions
+36
View File
@@ -0,0 +1,36 @@
"""The locator test client's framing survives fragmented timeout polls."""
import socket
import threading
import unittest
from unittest.mock import Mock
from locator_test_client import encode_packet, read_packet, recv_exactly
class LocatorClientTest(unittest.TestCase):
def test_partial_header_and_payload_survive_timeouts(self) -> None:
payload = {"vlc": 5.5}
packet = encode_packet(payload, 7)
sock = Mock()
sock.recv.side_effect = [packet[:3], socket.timeout(), packet[3:8],
packet[8:10], socket.timeout(), packet[10:]]
self.assertEqual(read_packet(sock), (7, payload))
def test_timeout_wait_can_be_stopped_without_losing_thread(self) -> None:
stop = threading.Event()
sock = Mock()
def receive(_size):
stop.set()
raise socket.timeout()
sock.recv.side_effect = receive
with self.assertRaisesRegex(ConnectionError, "stopped"):
recv_exactly(sock, 8, stop)
def test_eof_in_the_middle_of_packet_is_reported(self) -> None:
sock = Mock()
sock.recv.side_effect = [b"123", b""]
with self.assertRaisesRegex(ConnectionError, "closed"):
read_packet(sock)