Skip to content

Add coverage for critical auth, mutation, and PR logic paths#2151

Open
chronicgiardia wants to merge 2 commits into
Graphify-Labs:v8from
chronicgiardia:chronicgiardia-add-critical-path-tests
Open

Add coverage for critical auth, mutation, and PR logic paths#2151
chronicgiardia wants to merge 2 commits into
Graphify-Labs:v8from
chronicgiardia:chronicgiardia-add-critical-path-tests

Conversation

@chronicgiardia

Copy link
Copy Markdown
Contributor

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: new ingest() 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 _ApiKeyMiddleware covering missing key rejection, X-API-Key acceptance, case-insensitive Bearer acceptance, and non-HTTP passthrough.
  • tests/test_prs.py: business-logic coverage for fetch_prs() parsing/error paths and attach_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.

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>
Copilot AI review requested due to automatic review settings July 24, 2026 10:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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._ApiKeyMiddleware covering 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 and prs.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.

Comment thread tests/test_prs.py
Comment thread tests/test_serve.py Outdated
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants