Fix niggling bugs -- unclean shutdown, radio reconnect contention

This commit is contained in:
Jack Kingsman
2026-01-13 20:08:07 -08:00
parent 32ed00fd34
commit 2083e9c015
6 changed files with 50 additions and 99 deletions
-43
View File
@@ -478,49 +478,6 @@ class TestRawPacketRepository:
db._connection = original_conn
await conn.close()
@pytest.mark.asyncio
async def test_create_returns_none_for_duplicate_packet(self):
"""Second insert of same packet data returns None (duplicate)."""
import aiosqlite
from app.repository import RawPacketRepository
from app.database import db
# Use in-memory database for testing
conn = await aiosqlite.connect(":memory:")
conn.row_factory = aiosqlite.Row
# Create the raw_packets table
await conn.execute("""
CREATE TABLE raw_packets (
id INTEGER PRIMARY KEY,
timestamp INTEGER NOT NULL,
data BLOB NOT NULL UNIQUE,
decrypted INTEGER DEFAULT 0,
message_id INTEGER,
decrypt_attempts INTEGER DEFAULT 0,
last_attempt INTEGER
)
""")
await conn.commit()
# Patch the db._connection to use our test connection
original_conn = db._connection
db._connection = conn
try:
packet_data = b"\x01\x02\x03\x04\x05"
# First insert succeeds
first_id = await RawPacketRepository.create(packet_data, 1234567890)
assert first_id is not None
# Second insert of same data returns None
second_id = await RawPacketRepository.create(packet_data, 1234567891)
assert second_id is None
finally:
db._connection = original_conn
await conn.close()
@pytest.mark.asyncio
async def test_different_packets_both_stored(self):
"""Different packet data both get stored with unique IDs."""