Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added subprocess test client #3655

Merged
merged 13 commits into from
Jan 5, 2025

Conversation

aranvir
Copy link
Contributor

@aranvir aranvir commented Aug 3, 2024

Description

This introduces new helper functions to create sync and async test clients that can be used to test SSE endpoints with infinite generators as outlined in #3654 and https://github.com/orgs/litestar-org/discussions/3547.

The litestar cli is run in a subprocess to start a web app instance with a random port. The helper function then sets up a basic sync or async client.

The test code and doc example show how this can be used to test an SSE endpoint with an infinite generator.

Overview:

  • Adds subprocess_async_client and subprocess_sync_client
  • Tests both clients
  • Adds general documentation. Adds docs example for subprocess_async_client

Closes

Closes #3654

@aranvir aranvir requested review from a team as code owners August 3, 2024 12:19
@github-actions github-actions bot added area/docs This PR involves changes to the documentation area/private-api This PR involves changes to the privatized API area/testing size: small type/feat pr/external Triage Required 🏥 This requires triage labels Aug 3, 2024
@aranvir
Copy link
Contributor Author

aranvir commented Aug 3, 2024

Tests are failing because the redis fixture does not seem to work correctly. Tbh, added that as a best guess, so would need some help with fixing this. Alternatively, I just replace the test with a regular "does it connect and return the right thing" kind of test and ditch the SSE testing.

No idea why doc generation is failing.

@JacobCoffee
Copy link
Member

JacobCoffee commented Aug 12, 2024

Tests are failing because the redis fixture does not seem to work correctly. Tbh, added that as a best guess, so would need some help with fixing this. Alternatively, I just replace the test with a regular "does it connect and return the right thing" kind of test and ditch the SSE testing.

cc: @litestar-org/maintainers thought?

@cofin cofin force-pushed the feat/subprocess-test-client branch from cd6443e to 469a572 Compare August 25, 2024 01:09
@provinzkraut provinzkraut force-pushed the feat/subprocess-test-client branch from 469a572 to 7366207 Compare September 15, 2024 13:35
docs/usage/testing.rst Outdated Show resolved Hide resolved
docs/usage/testing.rst Outdated Show resolved Hide resolved
docs/usage/testing.rst Outdated Show resolved Hide resolved
@provinzkraut provinzkraut force-pushed the feat/subprocess-test-client branch from e4bc209 to baee5d7 Compare September 15, 2024 14:00
@provinzkraut provinzkraut enabled auto-merge (squash) September 15, 2024 14:00
@cofin cofin force-pushed the feat/subprocess-test-client branch from e61cd34 to 7a0659b Compare November 16, 2024 00:30
@cofin cofin removed the Triage Required 🏥 This requires triage label Jan 5, 2025
Copy link
Member

@cofin cofin left a comment

Choose a reason for hiding this comment

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

Simplified the test case a bit

Copy link

codecov bot commented Jan 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.36%. Comparing base (93aa6bf) to head (424c8f3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3655   +/-   ##
=======================================
  Coverage   98.36%   98.36%           
=======================================
  Files         346      347    +1     
  Lines       15690    15722   +32     
  Branches     1737     1737           
=======================================
+ Hits        15433    15465   +32     
  Misses        122      122           
  Partials      135      135           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cofin
Copy link
Member

cofin commented Jan 5, 2025

@all-contributors add @aranvir for docs, code, tests

Copy link
Contributor

@cofin

I've put up a pull request to add @aranvir! 🎉

@provinzkraut provinzkraut merged commit 8d67510 into litestar-org:main Jan 5, 2025
24 checks passed
Copy link

github-actions bot commented Jan 5, 2025

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3655

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs This PR involves changes to the documentation area/private-api This PR involves changes to the privatized API area/testing pr/external pr/internal size: small type/feat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Provide test client that can handle infinite SSE generators
4 participants