-
-
Notifications
You must be signed in to change notification settings - Fork 46
feature: add test infrastructure and developer testing guide (PR 1) #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add test infrastructure and developer testing guide (PR 1) #448
Conversation
- Add developer testing guide in docs/testing.md - Implement pytest fixtures in tests/conftest.py: - mock_session_factory for sequential response mocking - Response fixtures for login, errors, device info, hosts, xpath - Pre-configured client fixtures for all encryption methods - Add API response fixtures (6 JSON files) with realistic router responses - Add 4 example tests demonstrating key patterns: - Successful login with session state validation - Authentication error handling - XPath operations with sequential responses - Pre-configured fixture usage - Configure pytest in pyproject.toml: - Add pytest-asyncio, pytest-aiohttp, pytest-cov dependencies - Set asyncio_mode, testpaths, and markers Part of iMicknl#447: Add unit and integration tests to have test coverage
There was a problem hiding this 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 establishes comprehensive test infrastructure for the Sagemcom API client, including pytest configuration, mock fixtures, example tests, and developer documentation. The changes enable unit and integration testing with realistic API response mocking.
Key Changes:
- Added pytest configuration with asyncio support and coverage tooling
- Implemented mock session factory and response fixtures for authentication, errors, and data operations
- Created 6 JSON fixture files containing realistic router API responses
- Provided 4 example tests demonstrating key testing patterns
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Added pytest dependencies (pytest-asyncio, pytest-aiohttp, pytest-cov) and configuration for async tests, test paths, and custom markers |
| poetry.lock | Updated dependency lock file with new test-related packages and version constraints |
| tests/conftest.py | Implemented shared fixtures including mock session factory, response fixtures for various API scenarios, and pre-configured client fixtures for different encryption methods |
| tests/fixtures/login_success.json | Realistic API response for successful authentication with session ID and nonce |
| tests/fixtures/login_auth_error.json | API response demonstrating authentication failure error handling |
| tests/fixtures/login_invalid_session.json | API response for invalid session error scenario |
| tests/fixtures/device_info.json | Comprehensive device information response with 993 lines covering hardware, software, temperature sensors, and system configuration |
| tests/fixtures/hosts.json | Connected hosts/devices list response with detailed device metadata |
| tests/fixtures/xpath_value.json | Generic XPath query response demonstrating WiFi radio status retrieval |
| tests/unit/test_client_basic.py | Four example tests demonstrating mocking patterns for login success/failure, XPath operations, and pre-configured fixtures |
| docs/testing.md | Developer guide covering test structure, mocking strategies, fixture patterns, and instructions for running and adding tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
iMicknl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you!
(later we will need to add this to GitHub Actions as well)
Part of #447: Add unit and integration tests to have test coverage