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

Implement content, data and json patterns #106

Merged
merged 3 commits into from Nov 13, 2020
Merged

Conversation

lundberg
Copy link
Owner

@lundberg lundberg commented Nov 12, 2020

Adds support content, data and json patterns.

Match request content:

my_route = respx.post("https://example.org", content="foobar") % 201
response = httpx.post("https://example.org", content="foobar")
assert my_route.called
assert response.status_code == 201

Match request data:

my_route = respx.post("https://example.org", data={"field": "foobar"}) % 201
response = httpx.post("https://example.org", data={"field": "foobar"})
assert my_route.called
assert response.status_code == 201

Match request json:

my_route = respx.post("https://example.org", json={"name": "lundberg"}) % 201
response = httpx.post("https://example.org", json={"name": "lundberg"})
assert my_route.called
assert response.status_code == 201

Match request json, with path digging:

my_route = respx.post("https://example.org", json__name="lundberg") % 201
response = httpx.post("https://example.org", json={"name": "lundberg"})
assert my_route.called
assert response.status_code == 201

Ticks one box in #87.

@lundberg lundberg merged commit 937e371 into master Nov 13, 2020
@lundberg lundberg deleted the content-patterns branch November 13, 2020 15:15
lundberg added a commit that referenced this pull request Nov 13, 2020
Removed
- Dropped all deprecated APIs and models, see `0.15.0` Changed section. (PR #105)

Added
- Added support for content, data and json patterns. (PR #106)
- Automatic pattern registration when subclassing Pattern. (PR #108)

Fixed
- Multiple snapshots to support nested mock routers. (PR #107)
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.

None yet

1 participant