litestar icon indicating copy to clipboard operation
litestar copied to clipboard

feat: added subprocess test client

Open aranvir opened this issue 1 year ago • 2 comments

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 avatar Aug 03 '24 12:08 aranvir

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.

aranvir avatar Aug 03 '24 12:08 aranvir

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?

JacobCoffee avatar Aug 12 '24 21:08 JacobCoffee

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 05 '25 00:01 codecov[bot]

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

cofin avatar Jan 05 '25 00:01 cofin

@cofin

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

allcontributors[bot] avatar Jan 05 '25 00:01 allcontributors[bot]

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

github-actions[bot] avatar Jan 05 '25 01:01 github-actions[bot]