fix(tests): Move mock_driver fixture to module level for shared access

Fixes integration test failures where TestRealWorldScenario tests
couldn't access the mock_driver fixture.

The mock_driver fixture was defined inside TestPeripheralDisconnectCleanup
class, making it unavailable to TestRealWorldScenario class. This caused
pytest fixture lookup errors:

- test_both_monitoring_mechanisms_detect_disconnect_idempotent
- test_polling_catches_missed_dbus_signal

Solution: Move mock_driver to module level (outside class) so all test
classes can access it as a shared fixture.

All integration tests now pass locally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
torlando-tech 2025-11-15 20:26:04 -05:00
commit adb5544bff

View file

@ -45,24 +45,26 @@ if not hasattr(RNS, 'LOG_INFO'):
RNS.log = Mock()
# Module-level fixture (shared across test classes)
@pytest.fixture
def mock_driver():
"""Create a mock Linux BLE driver with GATT server capabilities."""
driver = Mock()
driver.loop = asyncio.new_event_loop()
driver._peers = {} # address -> peer_conn
driver._peers_lock = asyncio.Lock()
driver._log = Mock()
driver.on_device_disconnected = Mock()
# Mock method that should be added
driver._handle_peripheral_disconnected = Mock()
return driver
class TestPeripheralDisconnectCleanup:
"""Test peripheral disconnection cleanup mechanisms."""
@pytest.fixture
def mock_driver(self):
"""Create a mock Linux BLE driver with GATT server capabilities."""
driver = Mock()
driver.loop = asyncio.new_event_loop()
driver._peers = {} # address -> peer_conn
driver._peers_lock = asyncio.Lock()
driver._log = Mock()
driver.on_device_disconnected = Mock()
# Mock method that should be added
driver._handle_peripheral_disconnected = Mock()
return driver
@pytest.fixture
def mock_gatt_server(self, mock_driver):
"""Create a mock GATT server with connected centrals."""