responses icon indicating copy to clipboard operation
responses copied to clipboard

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

Open paulsuh opened this issue 1 year ago • 4 comments

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.

paulsuh avatar Jul 26 '24 14:07 paulsuh

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.

markstory avatar Jul 29 '24 14:07 markstory

and add deprecation notice + update readme + changelog

beliaev-maksim avatar Jul 29 '24 14:07 beliaev-maksim

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 🥀

getsantry[bot] avatar Aug 20 '24 07:08 getsantry[bot]

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

paulsuh avatar Sep 03 '24 18:09 paulsuh