responses icon indicating copy to clipboard operation
responses copied to clipboard

UX improvement: calls on callbacks

Open WilliamDEdwards opened this issue 11 months ago • 2 comments

The add method returns a BaseResponse, on which you can find calls using calls.

The add_callback method doesn't. Users can get calls from the generic RequestsMock object, but that requires searching for the right request, for which responses provides no native methods.

Solutions:

  • Let add_callback return BaseResponse (probably not possible)
  • Add built-in way to search for calls on the RequestsMock object, preferably those belonging to a specific response

WilliamDEdwards avatar Feb 10 '25 18:02 WilliamDEdwards

Found https://github.com/getsentry/responses?tab=readme-ov-file#assert-based-on-the-exact-url, which mostly does solution 2.

At the very least, I believe it should be documented that and why add_callback doesn't return a response.

WilliamDEdwards avatar Feb 10 '25 22:02 WilliamDEdwards

At the very least, I believe it should be documented that and why add_callback doesn't return a response.

There isn't a good reason other than it didn't do it in the past and no-one submitted a pull request to change it.

markstory avatar Feb 11 '25 15:02 markstory