mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-03-28 17:42:56 +01:00
- Update .flake8 and pre-commit config to properly use flake8 config - Add B008 to ignored errors (FastAPI Depends pattern) - Add E402 to ignored errors (intentional module-level imports) - Remove unused imports from test files and source files - Fix f-strings without placeholders - Add type annotations to inner async functions - Fix SQLAlchemy execute() to use text() wrapper - Add type: ignore comments for alembic.command imports - Exclude alembic/ directory from mypy in pre-commit - Update mypy overrides for test files to not require type annotations - Fix type annotations for params dicts in web routes - Fix generator return type in test fixtures
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""Fixtures for interface component tests."""
|
|
|
|
from collections.abc import Generator
|
|
|
|
import pytest
|
|
|
|
from meshcore_hub.interface.device import DeviceConfig
|
|
from meshcore_hub.interface.mock_device import MockDeviceConfig, MockMeshCoreDevice
|
|
|
|
|
|
@pytest.fixture
|
|
def device_config() -> DeviceConfig:
|
|
"""Create a device configuration for testing."""
|
|
return DeviceConfig(
|
|
port="/dev/ttyUSB0",
|
|
baud=115200,
|
|
timeout=1.0,
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_device_config() -> MockDeviceConfig:
|
|
"""Create a mock device configuration for testing."""
|
|
return MockDeviceConfig(
|
|
public_key="a" * 64,
|
|
name="TestNode",
|
|
enable_auto_events=False, # Disable auto events for testing
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_device(
|
|
device_config: DeviceConfig, mock_device_config: MockDeviceConfig
|
|
) -> Generator[MockMeshCoreDevice, None, None]:
|
|
"""Create a mock device instance for testing."""
|
|
device = MockMeshCoreDevice(device_config, mock_device_config)
|
|
yield device
|
|
if device.is_connected:
|
|
device.disconnect()
|