mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
Add command queue to command system
This commit is contained in:
parent
b0dd9d1123
commit
bb2b75e42e
6 changed files with 181 additions and 35 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
import pytest_asyncio
|
||||
import asyncio
|
||||
from unittest.mock import MagicMock, AsyncMock
|
||||
from meshcore.commands import CommandHandler
|
||||
|
|
@ -23,17 +24,23 @@ def mock_dispatcher():
|
|||
return dispatcher
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def command_handler(mock_connection, mock_dispatcher):
|
||||
@pytest_asyncio.fixture
|
||||
async def command_handler(mock_connection, mock_dispatcher):
|
||||
handler = CommandHandler()
|
||||
|
||||
async def sender(data):
|
||||
await mock_connection.send(data)
|
||||
|
||||
handler._sender_func = sender
|
||||
|
||||
handler.dispatcher = mock_dispatcher
|
||||
return handler
|
||||
|
||||
# Start the queue processor for tests
|
||||
await handler.start_queue_processor()
|
||||
|
||||
yield handler
|
||||
|
||||
# Clean up after tests
|
||||
await handler.stop_queue_processor()
|
||||
|
||||
|
||||
# Test helper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue