getsentry / responses

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

Cannot match with callback #727

Open jcampbell05 opened 1 month ago

jcampbell05 commented 1 month 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 1 month ago

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

jcampbell05 commented 1 month 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