test: add comprehensive unit tests achieving 99.83% coverage#9
Merged
Conversation
- Add pytest.ini with asyncio_mode=auto and pythonpath=src - Add tests/__init__.py and tests/conftest.py with shared fixtures - Add test_config.py: 100% coverage of config constants and types - Add test_services_history.py: 100% coverage of all history functions - Add test_services_http_client.py: 100% coverage of safe_request - Add test_services_massa_rpc.py: 100% coverage of RPC functions - Add test_services_price_api.py: 100% coverage of price API functions - Add test_services_system_monitor.py: 100% coverage of get_system_stats - Add test_services_docker_manager.py: 100% coverage of docker helpers - Add test_services_plotting.py: 100% coverage of all plot functions - Add test_handlers_common.py: 100% coverage of auth decorator and error handler - Add test_handlers_node.py: core node handler tests - Add test_handlers_node_docker.py: docker conversation handler tests (100%) - Add test_handlers_price.py: 100% coverage of btc and mas handlers - Add test_handlers_system.py: 100% coverage of hi/temperature/perf handlers - Add test_handlers_scheduler.py: scheduler and run_coroutine_in_loop tests - Add test_handlers_scheduler_extra.py: run_async_func and report-hour tests - Add test_jrequests.py: 100% coverage of backward-compat facade - Add test_main.py: 99% coverage of main.py (excluding entry-point guard) - Add test_coverage_gaps.py: targeted tests for remaining coverage gaps - Add test_final_gaps.py: tests for legacy year-rollback and outer exceptions - Add .github/workflows/tests.yml: CI workflow with --cov-fail-under=90 Total: 295 tests passing, 99% overall coverage (1199 stmts, 2 missed)
Copilot
AI
changed the title
[WIP] Add unit tests to achieve 90% code coverage
test: add comprehensive unit tests achieving 99.83% coverage
Mar 14, 2026
Owner
|
@copilot add a test_plan.md to explain the details in depth of each test |
Co-authored-by: lipnelz <174376617+lipnelz@users.noreply.github.com>
Contributor
Author
Added |
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.
No test suite existed. Adds 295 unit tests covering all source modules with 99.83% code coverage (requirement: ≥90%), runnable in CI — zero source files modified.
Test infrastructure
pytest.ini—pythonpath=src,asyncio_mode=auto.github/workflows/tests.yml— runs on every push/PR, enforces--cov-fail-under=90Coverage by module
config.py,jrequests.pyservices/history.pyservices/http_client.pyservices/massa_rpc.py,price_api.pyservices/system_monitor.pyservices/docker_manager.pyservices/plotting.pyhandlers/common.py,node.py,price.py,system.pyhandlers/scheduler.pymain.pyThe 2 uncovered lines are inherently untestable: the
if __name__ == '__main__':guard and a dead-code branch in the scheduler.Test approach
All external I/O is mocked — no network calls, no Docker socket, no real filesystem writes outside
tmp_path. Telegram handler tests useAsyncMockfor coroutine methods;conftest.pyprovides sharedmock_update/mock_contextfixtures and forces theAggmatplotlib backend.Documentation
test_plan.md— 696-line document describing every test case in depth, organized by file and class, including the scenario each test exercises and a consolidated mocking strategy summary.Original prompt
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.