Skip to content

Commit 14574eb

Browse files
committed
add test
1 parent 0919273 commit 14574eb

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/requests/test_params.py

+32
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,35 @@ def post_x(self, body: RequestBody) -> None:
8686
assert client.post_x(RequestBody(x=1, y="test")) is None
8787
assert mocker.called_once
8888
assert mocker.request_history[0].json() == {"x": 1, "y": "test"}
89+
90+
91+
def test_kwonly_param(session: requests.Session, mocker: requests_mock.Mocker):
92+
class Api(RequestsClient):
93+
@post("/post/")
94+
def post(
95+
self,
96+
*,
97+
body: RequestBody,
98+
) -> None:
99+
raise NotImplementedError
100+
101+
@get("/get/{id}")
102+
def get_x(self, *, id: str, param: str = "1") -> List[int]:
103+
raise NotImplementedError
104+
105+
mocker.post(
106+
url="http://example.com/post/",
107+
text="null",
108+
complete_qs=True,
109+
)
110+
mocker.get(
111+
url="http://example.com/get/x?param=1",
112+
text="[0]",
113+
complete_qs=True,
114+
)
115+
client = Api(base_url="http://example.com", session=session)
116+
assert client.post(body=RequestBody(x=1, y="test")) is None
117+
assert mocker.called_once
118+
assert mocker.request_history[0].json() == {"x": 1, "y": "test"}
119+
120+
assert client.get_x(id="x") == [0]

0 commit comments

Comments
 (0)