Skip to content

Commit 0148af9

Browse files
fix: dispatch_request unknown-method fallback returns callable not str (#157)
Fixes #151. .get(http_method, "GET") -> .get(http_method, self.session.get)
1 parent 8ab98a0 commit 0148af9

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

datamaxi/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def _dispatch_request(self, http_method):
200200
"DELETE": self.session.delete,
201201
"PUT": self.session.put,
202202
"POST": self.session.post,
203-
}.get(http_method, "GET")
203+
}.get(http_method, self.session.get)
204204

205205
def _handle_exception(self, response):
206206
raise_for_error(response.status_code, response.text, response.headers)

tests/test_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,9 @@ def test_API_context_manager_closes_session():
134134
client.session.close = lambda: setattr(client.session, "closed", True)
135135
assert client.__enter__() is client
136136
assert client.session.closed is True
137+
138+
139+
def test_dispatch_request_unknown_method_falls_back_to_get():
140+
"""Unknown HTTP methods should fall back to a callable (session.get), not a string."""
141+
client = API()
142+
assert client._dispatch_request("PATCH") == client.session.get

0 commit comments

Comments
 (0)