test: cover untested behavioral branches (#44)#46
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds regression tests to ensure resumed-session runtime is calculated from last_resume_time, improves parser robustness around malformed config.json model fields, and adds coverage for CLI watchdog observer utilities.
Changes:
- Add report rendering tests to verify
last_resume_timetakes precedence overstart_timewhen computing “running time”. - Add parser tests ensuring non-string
config.json["model"]values result insummary.model is None. - Add CLI tests for
_stop_observer(None)and_FileChangeHandlerdebounce behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/copilot_usage/test_report.py | New regression tests for “running time” display using last_resume_time in live + full summary views. |
| tests/copilot_usage/test_parser.py | New tests for config model parsing when model is invalid type (int/null/list). |
| tests/copilot_usage/test_cli.py | New tests for observer stop guard and file-change debounce behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add tests for three uncovered behavioral branches:
1. report.py: render_live_sessions and _render_active_section now have
tests verifying that last_resume_time is used over start_time when
both are set.
2. cli.py: _FileChangeHandler.dispatch debounce logic is tested for
first-call event setting, suppression within 2s, and re-firing
after the debounce window. _stop_observer(None) no-op guard is
also tested.
3. parser.py: _read_config_model non-string model values ({"model": 42},
{"model": null}, {"model": []}) are tested to return None.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use large time gaps (days vs minutes) for resume-time assertions and explicitly set _last_trigger for debounce test determinism. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
66790d8 to
cac623c
Compare
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.
Closes #44
Changes
Adds direct test coverage for three behavioral branches that had no tests:
1.
last_resume_timedisplay inreport.pyTestRenderLiveSessions.test_last_resume_time_used_over_start_time— verifiesrender_live_sessionsshows duration fromlast_resume_time(notstart_time) when both are set.TestRenderFullSummary.test_active_section_uses_last_resume_time— same guarantee for_render_active_sectionin the full summary view.2.
_FileChangeHandlerdebounce incli.pyTestFileChangeHandler.test_dispatch_sets_event_on_first_call— first dispatch sets the change event.TestFileChangeHandler.test_dispatch_suppresses_within_debounce_window— rapid second call within 2 s is suppressed.TestFileChangeHandler.test_dispatch_fires_again_after_debounce_gap— dispatch fires again after > 2 s gap.test_stop_observer_none_is_noop—_stop_observer(None)returns without raising.3.
_read_config_modelnon-string values inparser.pytest_config_model_integer_returns_none—{"model": 42}→Nonetest_config_model_null_returns_none—{"model": null}→Nonetest_config_model_list_returns_none—{"model": []}→NoneTesting
All 10 new tests follow existing patterns and conventions. No source code changes — tests only.
Warning
The following domains were blocked by the firewall during workflow execution:
astral.shpypi.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.