feat: Set up comprehensive Python testing infrastructure #149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Set up Python Testing Infrastructure
Summary
This PR establishes a complete testing infrastructure for the Home Assistant Tion BTLE custom component project using Poetry as the package manager.
Changes Made
Package Management: Configured Poetry with
pyproject.tomlincluding project metadata and dependenciesTesting Dependencies: Added core testing packages:
pytest(^8.0.0) - Main testing frameworkpytest-cov(^4.0.0) - Coverage reportingpytest-mock(^3.12.0) - Mocking utilitiespytest-asyncio(^0.23.0) - Async testing supportTesting Configuration: Comprehensive pytest configuration in
pyproject.toml:unit,integration,slowDirectory Structure:
Shared Fixtures: Created comprehensive fixtures in
conftest.py:temp_dir- Temporary directory for test filesmock_config_entry- Mock Home Assistant config entrymock_hass- Mock Home Assistant instancemock_ble_device- Mock Bluetooth devicemock_tion_device- Mock Tion device with realistic responsessample_device_data- Realistic test dataDevelopment Scripts: Poetry commands for easy testing:
poetry run test- Run all testspoetry run tests- Alternative command (both work identically)Git Configuration: Updated
.gitignorewith:.pytest_cache/,.coverage,htmlcov/,coverage.xml).claude/*)Instructions for Running Tests
Install dependencies:
Run all tests:
Run specific test categories:
Generate coverage reports:
Run with different verbosity:
Validation
The setup includes validation tests (
tests/test_validation.py) that verify:Test Results: All 9 validation tests pass, confirming the testing infrastructure is ready for use.
Configuration Choices
unit,integration, andslowfor flexible test categorizationNext Steps
Developers can now:
tests/unit/tests/integration/The testing infrastructure is production-ready and follows Python testing best practices.