test: strengthen focused unit coverage for core behavior#2397
test: strengthen focused unit coverage for core behavior#2397PeterDaveHello wants to merge 1 commit into
Conversation
Review Summary by QodoComprehensive unit test coverage for core PR-Agent behavior and security hardening
WalkthroughsDescription• Adds comprehensive unit test coverage for core PR-Agent functionality across 15 new test modules • **Markdown and Output Rendering**: Tests for convert_to_markdown_v2, ticket extraction, and PR description generation with structural marker validation • **Diff Processing Pipeline**: Tests for hunk processing, file deletion handling, token budgeting, and pagination logic • **GitHub App Integration**: Tests for timeout dict behavior, GitHub app events, push trigger deduplication, and webhook signature verification • **Code Suggestions**: Tests for filtering, quality guards, rendering, and output formatting with truncation and score thresholds • **Ticket Extraction**: Async tests for GitHub and Azure DevOps provider integration with deduplication and caching • **Provider Helpers**: Tests for GitHub provider comment publishing, URL parsing, diff handling, and inline code suggestions • **Configuration Security**: Tests for repository settings application, CLI argument validation, and custom merge loader with forbidden directive detection • **Retry Logic**: Tests for async retry with fallback model chains and deployment ID updates • **Test Infrastructure**: Adds _settings_helpers.py module providing snapshot_settings and restore_settings utilities for reliable test isolation with Dynaconf settings • All tests use structural marker validation and fake providers to avoid network calls and LLM dependencies • Tests maintain order-independence through proper settings state management and cleanup Diagramflowchart LR
A["Test Infrastructure<br/>_settings_helpers.py"] --> B["Configuration Security<br/>Settings/CLI/Loader"]
A --> C["Output Rendering<br/>Markdown/PR Description"]
A --> D["Code Suggestions<br/>Filtering/Rendering"]
B --> E["Integration Tests<br/>Settings Application"]
C --> F["Diff Pipeline<br/>Hunk Processing"]
D --> G["Provider Helpers<br/>Comments/Suggestions"]
F --> H["Ticket Extraction<br/>Async Providers"]
G --> I["GitHub App<br/>Events/Timeouts"]
H --> J["Retry Logic<br/>Fallback Models"]
I --> K["Webhook Verification<br/>Signature Checks"]
File Changes1. tests/unittest/test_markdown_ticket_output_core.py
|
Code Review by Qodo
1. ask_diff_hunk unset can raise
|
1ece758 to
370b0b8
Compare
|
Persistent review updated to latest commit 370b0b8 |
| if original is sentinel: | ||
| settings.unset("ask_diff_hunk", force=True) | ||
| else: | ||
| settings.set("ask_diff_hunk", original) |
There was a problem hiding this comment.
1. ask_diff_hunk unset can raise 📘 Rule violation ☼ Reliability
_restore_ask_diff_hunk calls settings.unset("ask_diff_hunk", force=True) without handling
KeyError for keys that were never set. This can break teardown and leak process-global Dynaconf
state, creating order-dependent/flaky tests.
Agent Prompt
## Issue description
A test cleanup helper unsets `ask_diff_hunk` without guarding against `KeyError` when the key was never set, which can cause teardown failures and leave process-global settings in a dirty state.
## Issue Context
Other new test helpers document that Dynaconf `settings.unset(..., force=True)` may raise `KeyError` for keys that were never set; cleanup code should treat that case as benign.
## Fix Focus Areas
- tests/unittest/test_github_app_timeout_core.py[42-45]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
There was a problem hiding this comment.
Verified locally: missing ask_diff_hunk does not raise on unset, so no change needed. Please help confirm.
Cover PR processing, provider helpers, review output rendering, configuration behavior, retry handling, ticket extraction, code suggestions, and GitHub app workflows. These tests target behavior that is important and likely to change, while keeping production code untouched. They also isolate shared test state so the new coverage remains order-independent. This work was developed through multiple rounds of human-led AI collaboration using codex-cli v0.130.0 with GPT-5.5, GitHub Copilot CLI v1.0.48 with GPT-5.5, and Claude Opus 4.7.
370b0b8 to
8a7c33e
Compare
|
Persistent review updated to latest commit 8a7c33e |
Cover PR processing, provider helpers, review output rendering, configuration behavior, retry handling, ticket extraction, code suggestions, and GitHub app workflows.
These tests target behavior that is important and likely to change, while keeping production code untouched. They also isolate shared test state so the new coverage remains order-independent.
This work was developed through multiple rounds of human-led AI collaboration using codex-cli v0.130.0 with GPT-5.5, GitHub Copilot CLI v1.0.48 with GPT-5.5, and Claude Opus 4.7.
cc #2373
GitHub Copilot Pull Request Summary