Skip to content

Conversation

@allenporter
Copy link
Contributor

Rewrite the test fixtures to have a more clear split between local and mqtt fixtures. This is in prepration for running both at once for e2 tests for device manager.

All fixtures are moved into a fixtures subdirectory. The helper classes that are imported into other tests are added in separate files for importing, and to avoid import warnings from pytests.

This renames all the fixtures to have mqtt prefixed names and local fixtures to have local prefixed names. There is one minor change to make the local asyncio tests uses asyncio Queues rather than blocking queues.

Copilot AI review requested due to automatic review settings December 22, 2025 01:26
AsyncLocalRequestHandler = Callable[[bytes], Awaitable[bytes | None]]


@pytest.fixture(name="local_received_requests")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was copied, then modified to use asyncio.Queue instead of queue.Queue

LocalRequestHandler = Callable[[bytes], bytes | None]


@pytest.fixture(name="local_received_requests")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The synchronous local request handler fixtures were moved here since it is only used by this test.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reorganizes test fixtures to improve structure and prepare for end-to-end testing of the device manager. The changes move all fixtures into a dedicated tests/fixtures/ subdirectory and introduce consistent naming conventions with mqtt_ and local_ prefixes to clarify fixture purposes.

Key changes:

  • Reorganized all test fixtures into a new tests/fixtures/ subdirectory with separate files by concern (logging, MQTT, local connections, web API)
  • Renamed fixtures with mqtt_ and local_ prefixes for better clarity and to enable running both fixture types simultaneously
  • Converted local async test fixtures to use asyncio.Queue instead of blocking Queue for better async compatibility

Reviewed changes

Copilot reviewed 21 out of 22 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
tests/conftest.py Removed - all fixtures moved to dedicated files in fixtures subdirectory
tests/fixtures/init.py Added as package marker for new fixtures subdirectory
tests/fixtures/logging.py Created helper module with CapturedRequestLog class for test imports
tests/fixtures/logging_fixtures.py Created fixture module with logging-related fixtures and CapturedRequestLog (duplicated)
tests/fixtures/pahomqtt_fixtures.py Created fixtures for Paho MQTT client mocking with mqtt_ prefix
tests/fixtures/mqtt.py Created helper module with MQTT test utilities like FakeMqttSocketHandler and Subscriber
tests/fixtures/aiomqtt_fixtures.py Updated to import from new mqtt.py helper module
tests/fixtures/local_async_fixtures.py Created async local connection fixtures using asyncio.Queue
tests/fixtures/channel_fixtures.py Created helper with FakeChannel class for channel testing
tests/fixtures/web_api_fixtures.py Created fixtures for web API REST endpoint mocking
tests/test_web_api.py Updated imports and added pytest_plugins configuration
tests/test_local_api_v1.py Moved local fixtures inline, updated imports with local_ prefix
tests/test_api.py Updated to use mqtt_ prefixed fixtures and new imports
tests/test_a01_api.py Updated to use mqtt_ prefixed fixtures and new imports
tests/mqtt/test_roborock_session.py Updated fixture references to use mqtt_ prefix
tests/e2e/init.py Added pytest_plugins configuration for e2e tests
tests/e2e/test_mqtt_session.py Updated fixture references to use new naming
tests/e2e/test_local_session.py Updated to use async local fixtures with asyncio.Queue
tests/devices/test_v1_channel.py Updated import to use FakeChannel from fixtures.channel_fixtures
tests/devices/test_a01_channel.py Updated import to use FakeChannel from fixtures.channel_fixtures
tests/devices/traits/a01/test_init.py Updated import to use FakeChannel from fixtures.channel_fixtures
tests/devices/traits/b01/test_init.py Updated import to use FakeChannel from fixtures.channel_fixtures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Rewrite the test fixtures to have a more clear split between local and mqtt fixtures. This is in prepration for running both at once for e2 tests for device manager.

All fixtures are moved into a fixtures subdirectory. The helper classes that are imported into other tests are added in separate files for importing, and to avoid import warnings from pytests.

This renames all the fixtures to have mqtt prefixed names and local fixtures to have local prefixed names. There is one minor change to make the local asyncio tests uses asyncio Queues rather than blocking queues.
@allenporter allenporter merged commit c317f8e into Python-roborock:main Dec 23, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants