Skip to content

Conversation

DoctorJohn
Copy link
Member

@DoctorJohn DoctorJohn commented May 24, 2025

Description

This PR extends the operation selection tests of both GraphQL over WS protocols.

There's still some work left in this area, but I'll do that in a separate PR to keep things reviewable.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Summary by Sourcery

Extend operation selection test coverage for both GraphQL over WS protocols by parametrizing multi‐operation queries to test default, null, and named operationName payloads in subscription and single‐result scenarios.

Tests:

  • Parameterize subscription tests in both graphql-transport-ws and graphql-ws to verify selecting default, None, and specific named operations yields expected messages.
  • Parameterize single‐result query tests in graphql-transport-ws to cover operationName variations between Query1 and Query2.
  • Replace send_message with send_json for consistency when sending JSON payloads in tests.
  • Update test queries to emit unique echo/hello messages per operation variant for clearer validation.

Copy link
Contributor

sourcery-ai bot commented May 24, 2025

Reviewer's Guide

Extends and parameterizes operation selection tests across both GraphQL over WS protocols by adding new subscription tests and refactoring existing single-result query tests with dynamic payload handling, updated send methods, and assertions.

File-Level Changes

Change Details Files
Introduce parameterized operation selection tests for subscriptions
  • Added new pytest.mark.parametrize tests covering default, None, and specific operationName cases
  • Sent subscribe/start messages with **extra_payload for both transport and legacy protocols
  • Asserted responses using dynamic expected_message values and completed operations appropriately
tests/websockets/test_graphql_transport_ws.py
tests/websockets/test_graphql_ws.py
Refactor single-result query operation selection to parametrized format
  • Converted test_single_result_operation_selection to pytest.mark.parametrize with extra_payload and expected_message
  • Updated GraphQL query arguments to differentiate Query1 and Query2 results
  • Replaced send_message calls with send_json and spread extra_payload in payload
  • Adjusted assertions to verify expected_message dynamically
tests/websockets/test_graphql_transport_ws.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@DoctorJohn DoctorJohn requested a review from bellini666 May 24, 2025 16:17
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Extended operation selection tests for both GraphQL WebSocket protocols by introducing parameterized test cases to verify different operation selection scenarios.

  • Added parameterized tests in tests/websockets/test_graphql_transport_ws.py to cover both subscription and single-result operations
  • Replaced single operation test with parameterized version in tests/websockets/test_graphql_ws.py to test default, None, and named operations
  • Enhanced test coverage for operation selection with different payload configurations
  • Added verification for correct message handling and operation execution based on operation names

💡 (3/5) Reply to the bot's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @DoctorJohn - I've reviewed your changes - here's some feedback:

  • Extract the duplicated parametrization data into a shared constant or fixture to DRY up the operation selection tests across both WebSocket test modules.
  • Unify the test client API calls (send_json vs send_message/send_legacy_message) across both protocols to keep the test interfaces consistent and clear.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

codecov bot commented May 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.02%. Comparing base (66a1350) to head (3fdbcd8).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3868   +/-   ##
=======================================
  Coverage   95.01%   95.02%           
=======================================
  Files         509      509           
  Lines       33194    33208   +14     
  Branches     1728     1728           
=======================================
+ Hits        31539    31555   +16     
+ Misses       1373     1371    -2     
  Partials      282      282           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

codspeed-hq bot commented May 24, 2025

CodSpeed Performance Report

Merging #3868 will not alter performance

Comparing DoctorJohn:test-graphql-over-ws-operation-selection (3fdbcd8) with main (66a1350)

Summary

✅ 21 untouched benchmarks

@DoctorJohn DoctorJohn merged commit 3df7f04 into strawberry-graphql:main May 28, 2025
96 checks passed
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