feature: add test infrastructure and developer testing guide (PR 1)#448
Merged
iMicknl merged 2 commits intoiMicknl:mainfrom Dec 29, 2025
Merged
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
Contributor
There was a problem hiding this comment.
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 <175728472+Copilot@users.noreply.github.com>
iMicknl
approved these changes
Dec 29, 2025
Owner
iMicknl
left a comment
There was a problem hiding this comment.
Looks good to me! Thank you!
(later we will need to add this to GitHub Actions as well)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #447: Add unit and integration tests to have test coverage