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

Add ParsedRequest assertions helper #12

Merged
merged 29 commits into from
Mar 21, 2024

Conversation

DevL
Copy link
Contributor

@DevL DevL commented Mar 1, 2024

This PR adds a ParsedRequest class that can be used in any existing assertions function to parse the PreparedRequest in order to access convenience functions and properties such as parsing the URL into endpoint and query portions or parsing the body bytes into text or as JSON.

It was considered to make ParsedRequest a subclass of PreparedRequest and then pass it directly to all assertions functions, but this could prove brittle if requests would change the PreparedRequest object. Still a possibility though. Another idea is to start providing the ParsedRequest object directly to assertions functions (without making it into a subclass), but this would be a breaking change and thus a candidate for a 2.0 release.

Closes #4
Closes #13

@DevL DevL added the enhancement New feature or request label Mar 1, 2024
@DevL DevL added this to the 1.2 milestone Mar 1, 2024
@DevL DevL self-assigned this Mar 1, 2024
@DevL DevL linked an issue Mar 1, 2024 that may be closed by this pull request
@DevL
Copy link
Contributor Author

DevL commented Mar 1, 2024

This begins the development cycle of 1.2.0(-dev) by practicing a wee bit of RDD. 😉

src/requtests/__init__.py Outdated Show resolved Hide resolved
DevL added 2 commits March 1, 2024 13:15
We only need to use the ParsedRequest constructor.
@DevL
Copy link
Contributor Author

DevL commented Mar 1, 2024

Once implemented, we may want to consider always passing a ParsedRequest object to the assertions functions. This would entail bumping the version to 2.0 as it's a breaking change.

@DevL DevL linked an issue Mar 1, 2024 that may be closed by this pull request
@DevL DevL changed the title Add ParsedRequest and parse_request assertions helpers Add ParsedRequest assertions helper Mar 1, 2024
@DevL DevL force-pushed the add-assertion-helpers-for-prepared-requests branch from 742f9f3 to aa20c03 Compare March 1, 2024 14:32
@DevL DevL marked this pull request as ready for review March 20, 2024 09:09
@DevL DevL added the documentation Improvements or additions to documentation label Mar 20, 2024
@DevL DevL merged commit 2eabdb8 into master Mar 21, 2024
5 checks passed
@DevL DevL deleted the add-assertion-helpers-for-prepared-requests branch March 21, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add type hints Add assertion helpers for prepared requests
4 participants