getsentry / responses

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

RequestsMock.add() and .upsert() parameter names are different #734

Open paulsuh opened 3 months ago

paulsuh commented 3 months ago

It's just a little pain point, but .add() uses method while .upsert() uses method_or_response for the HTTP method parameter name. Both can use the same actual values, but the formal names are different.

Why is this a problem (at least for me)? I will sometimes send in the inputs by applying ** to a dict. If the formal parameter names are different, it's a PITA to change the dict keys if I have to swap .add() vs. .upsert().

arg_dict = {
    "method": "GET",
    "url": "https://www.cnn.com/",
    # ...
}
responses.add(**arg_dict)    # this works
responses.upsert(**arg_dict)    # this doesn't

If you think it's worthwhile I can create a little PR to change it.

markstory commented 3 months ago

If you think it's worthwhile I can create a little PR to change it.

That would be great. We can't remove the method_or_reponse parameter because it would needlessly break compatibility, but adding a method parameter would work. An exception could be raised if both method and method_or_response are provided would be good too.

beliaev-maksim commented 3 months ago

and add deprecation notice + update readme + changelog

getsantry[bot] commented 2 months ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

paulsuh commented 2 months ago

I'm finally getting a few cycles to work on it