Add coverage for critical auth, mutation, and PR logic paths#2151
Open
chronicgiardia wants to merge 2 commits into
Open
Add coverage for critical auth, mutation, and PR logic paths#2151chronicgiardia wants to merge 2 commits into
chronicgiardia wants to merge 2 commits into
Conversation
Add comprehensive tests for ingest mutation flows, ASGI API-key auth middleware behavior, and PR impact/fetch business logic paths that were under-covered. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds new test coverage for several high-risk paths in the Graphify codebase—API key authorization middleware, URL ingest behaviors, and PR/business-logic impact computation—without changing production code.
Changes:
- Added direct raw-ASGI tests for
serve._ApiKeyMiddlewarecovering missing/valid API key scenarios and non-HTTP scope passthrough. - Added
ingest()tests for webpage writes, overwrite-avoidance behavior, binary (PDF/image) branches, and error wrapping. - Added tests for
prs.fetch_prs()parsing/error handling andprs.attach_graph_impact()behavior for actionable vs wrong-base PRs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_serve.py | Adds an in-process ASGI harness and tests for _ApiKeyMiddleware authorization behavior. |
| tests/test_prs.py | Adds coverage for fetch_prs() parsing/failure and attach_graph_impact() population rules. |
| tests/test_ingest.py | Adds coverage for ingest() output paths, overwrite prevention, type branching, and error wrapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use a dynamic updatedAt value in fetch_prs tests to avoid time-based staleness failures, and mark the unused ASGI helper parameter as intentionally unused for clarity. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.
Why
These paths carry high risk and were under-covered: HTTP API key authorization, content-ingest mutation flows, and PR impact/business logic. Gaps here can cause silent auth bypasses, bad persistence behavior, or incorrect PR triage output.
What changed
This adds comprehensive tests across the three critical areas:
tests/test_ingest.py: newingest()coverage for webpage writes, non-overwrite filename suffixing, PDF/image branches, URL validation wrapping, and fetch error wrapping.tests/test_serve.py: direct ASGI tests for_ApiKeyMiddlewarecovering missing key rejection,X-API-Keyacceptance, case-insensitive Bearer acceptance, and non-HTTP passthrough.tests/test_prs.py: business-logic coverage forfetch_prs()parsing/error paths andattach_graph_impact()population rules, including actionable-only diff fetching and correct community/node impact assignment.Notes for reviewers
The changes are test-only and focused on correctness for existing behavior; no production code paths were modified.