getsentry / responses

A utility for mocking out the Python Requests library.
Apache License 2.0
4.17k stars 355 forks source link

Cannot match with callback #727

Open jcampbell05 opened 4 months ago

jcampbell05 commented 4 months ago

Describe the bug

When using standard responses you can use the matching behaviour but the callback API doesn't currently allow you to assert any calls to this callback

Additional context

No response

Version of responses

0.25.3

Steps to Reproduce

  1. Register callback 2.API currently returns None

Expected Result

API returns response we can then use with assert

Actual Result

The api returns none so we can't assert against it

markstory commented 4 months ago

Could you share an example of the code you're trying to make work?

jcampbell05 commented 4 months ago
resp =   self.responses.add_callback(
                responses.POST,
                'http://example.com',
                callback=fetch_invoice_pdf # Returns {}
 )
assert resp.calls[0].request.body == {}

Currently resp will be None because add_callback returns None