Skip to content

🧪 Add tests for GraphQLResponse.data fallback and missing coverage#333

Merged
abn merged 2 commits intomainfrom
test-graphqlresponse-data-fallback-4022231266722643061
Mar 24, 2026
Merged

🧪 Add tests for GraphQLResponse.data fallback and missing coverage#333
abn merged 2 commits intomainfrom
test-graphqlresponse-data-fallback-4022231266722643061

Conversation

@abn
Copy link
Copy Markdown
Owner

@abn abn commented Mar 24, 2026

🎯 What: The testing gap addressed is the edge case in GraphQLResponse.data when the json is initialized with {'data': None}. Due to the way isinstance(None, dict) evaluates to False, the property gracefully falls back to returning an empty dictionary {}, but this behavior lacked explicitly targeted tests.

📊 Coverage: The following scenarios are now additionally tested:

  • GraphQLResponse.data returning {} when {'data': None} is provided in JSON.
  • GraphQLResponse.errors returning [] when {'errors': None} or no 'errors' key is present.
  • GraphQLResponse.query evaluating correctly when initialized with a true GraphQLRequest object instead of a string.
  • GraphQLResponse.data_as functioning correctly when extracting to a dict without providing a navigation path.

Result: The improvement in test coverage increases the test coverage of src/aiographql/client/response.py to a full 100%. These tests act as a safety net against regressions in how invalid or semi-valid GraphQL response payloads are handled.


PR created automatically by Jules for task 4022231266722643061 started by @abn

Adds a test to ensure `GraphQLResponse.data` correctly falls back to an empty dictionary `{}` when the response json provides `{'data': None}`.

Also adds tests for `GraphQLResponse.errors` fallback and `GraphQLResponse.query` with a mock request object, bringing the coverage of `src/aiographql/client/response.py` up to 100%.

Co-authored-by: abn <165325+abn@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 24, 2026
@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Add comprehensive tests for GraphQLResponse edge cases

🧪 Tests

Grey Divider

Walkthroughs

Description
• Add tests for GraphQLResponse.data fallback when data is None
• Add tests for GraphQLResponse.errors fallback scenarios
• Add test for GraphQLResponse.query with GraphQLRequest object
• Add test for data_as() method without path parameter
• Achieve 100% test coverage for src/aiographql/client/response.py
Diagram
flowchart LR
  A["GraphQLResponse edge cases"] --> B["data fallback with None"]
  A --> C["errors fallback scenarios"]
  A --> D["query with GraphQLRequest object"]
  A --> E["data_as without path"]
  B --> F["100% coverage achieved"]
  C --> F
  D --> F
  E --> F
Loading

Grey Divider

File Changes

1. tests/test_response.py 🧪 Tests +34/-0

Add edge case tests for GraphQLResponse properties

• Added test_graphql_response_data_fallback() to verify data returns {} when json contains
 {'data': None}
• Added test_graphql_response_errors_fallback() to test errors fallback for None and missing keys,
 plus valid error handling
• Extended test_graphql_response_coverage() with test for query property when request is a
 GraphQLRequest object
• Added test for data_as() method without path parameter to extract entire data dict

tests/test_response.py


Grey Divider

Qodo Logo

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Mar 24, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 📐 Spec deviations (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@dosubot dosubot Bot added the python Pull requests that update Python code label Mar 24, 2026
Updates `apollo-server-v2` and `strawberry-server` to use more stable and modern base image tags (`node:20-alpine` and `python:3.13-slim` respectively) to prevent intermittent HTTP 504 Gateway Time-out errors from Docker Hub during `podman compose up` in CI.

Additionally, removes the deprecated `debug-server` extra from the `strawberry-graphql` dependencies to allow successful installations.

Co-authored-by: abn <165325+abn@users.noreply.github.com>
@abn abn merged commit f4d3ca9 into main Mar 24, 2026
21 checks passed
@abn abn deleted the test-graphqlresponse-data-fallback-4022231266722643061 branch March 24, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests that update Python code size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant