This directory contains tests for the Example Integration.
conftest.py- Shared fixtures and mockstest_*.py- Test modules (to be implemented)
-
test_config_flow.py- Config flow tests- User flow success
- Connection error handling
- Authentication error handling
- Duplicate prevention
-
test_init.py- Setup/unload tests- Successful setup
- Setup failure handling
- Unload entry
# Activate virtual environment
source venv/bin/activate
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=custom_components.example_integration --cov-report=html
# Run specific test file
pytest tests/test_config_flow.py -v- All I/O operations must be mocked
- Tests must not require a running Home Assistant instance
- Use
AsyncMockfor async operations - Use the
hassfixture provided by pytest-homeassistant-custom-component