question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: easy assertions on post data

See original GitHub issue
@responses.activate
def foo():
        responses.add(responses.POST, 'http://foo.bar')
        requests.post('http://foo.bar', {'qux': 'quux'})

I would like to assert that I’ve posted qux=quux, but doing this completely well is uncomfortable (esp. if you want to be py2-3 compatible).

Ideally, I would like to do:

assert responses.calls[0].data = {'qux': 'quux'}

or something equivalent.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:7
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dcramercommented, Jun 26, 2018

This is possible today, and while we could add a million new APIs, I’m closing this to avoid noise.

    assert responses.calls[0].response.text == '{"value": 6}'
    assert (
        responses.calls[0].response.headers['request-id'] ==
        '728d329e-0e86-11e4-a748-0c84dc037c13'
    )
0reactions
rdreycommented, Jun 26, 2018

Would be nice if it could “match” on body params. That way it would raise if different params were sent (nothing matched).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automating Response Validation With Assertions In Postman
This tutorial explains the concept of assertions and tests in Postman requests. This is a powerful feature to create really robust & fast ......
Read more >
Making assertions - Assertible
Assertions allow you to validate HTTP responses in your API tests. For example, a basic assertion would ensure that a request to assertible.com...
Read more >
Postman: Automating Response Validation With Assertions
... This tutorial will explain the concept of assertions and tests in Postman requests. This is a powerful feature and could help to...
Read more >
Getting started with Assertions | Functional Testing - SoapUI
Assertions are used to validate the message received by a TestStep during execution, usually by comparing parts of the message (or the entire...
Read more >
Validating Responses with Assertions - BlazeMeter Docs
Assertions allow you to specify expected data in the response to a request made in a test run. When a test is run,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found