mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-07-06 01:42:11 +02:00
Fix niggling bugs -- unclean shutdown, radio reconnect contention
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user