-
-
Notifications
You must be signed in to change notification settings - Fork 944
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(testing): improve create_req
and create_asgi_req
#2249
base: master
Are you sure you want to change the base?
Conversation
enable passing `json`, `params`, `params_csv`, `content_type` enable passing arbitrary WSGI envs through `extras` do extra checks on request attributes through `_prepare_sim_args` move `_prepare_sim_args` to `helpers.py`
I submitted this as a draft because I plan on addressing remaining changes in #1793 in the following days. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2249 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 63 63
Lines 7112 7124 +12
Branches 1260 1264 +4
=========================================
+ Hits 7112 7124 +12 ☔ View full report in Codecov by Sentry. |
* enable passing `json`, `params`, `params_csv`, `content_type`, `extras` * do extra checks on request attributes through `_prepare_sim_args` * set Content-Length if not passed * add extras to ASGI scope
* test was failing with a TypeError (expected str, got MagicMock) * keep mocked function behaviour by using a side_effect
create_req
and create_asgi_req
Hi Iuliana, and thanks once again for Sprinting in Prague! |
Hi Vytautas! Thank you for the opportunity and the guidance! I will get back to it this week, if it't not too late, sorry for the delay! |
Summary of Changes
This PR changes
create_req
andcreate_asgi_req
to make their behaviour consistent withsimulate_request
by:content_type
,json
,params
,params_csv
_prepare_sim_args
function (which was also moved tohelpers.py
), which does a series of checks on request attributes and setsContent-Type
extra
argumentRelated Issues
#1793
Pull Request Checklist
docs/
.docs/
.versionadded
,versionchanged
, ordeprecated
directives.docs/_newsfragments/
, with the file name format{issue_number}.{fragment_type}.rst
. (Runtowncrier --draft
to ensure it renders correctly.)If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!
PR template inspired by the attrs project.