From a14b7fdcf62744cf711499824f2076d00ce803da Mon Sep 17 00:00:00 2001 From: Martin Kersner Date: Sat, 4 Jul 2026 15:20:38 +0900 Subject: [PATCH] fix: dispatch_request unknown-method fallback returns callable not str Fixes #151. .get(http_method, "GET") -> .get(http_method, self.session.get) --- datamaxi/api.py | 2 +- tests/test_api.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/datamaxi/api.py b/datamaxi/api.py index d004095..5fd1a0b 100644 --- a/datamaxi/api.py +++ b/datamaxi/api.py @@ -200,7 +200,7 @@ def _dispatch_request(self, http_method): "DELETE": self.session.delete, "PUT": self.session.put, "POST": self.session.post, - }.get(http_method, "GET") + }.get(http_method, self.session.get) def _handle_exception(self, response): raise_for_error(response.status_code, response.text, response.headers) diff --git a/tests/test_api.py b/tests/test_api.py index f7a4613..e3081e7 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -134,3 +134,9 @@ def test_API_context_manager_closes_session(): client.session.close = lambda: setattr(client.session, "closed", True) assert client.__enter__() is client assert client.session.closed is True + + +def test_dispatch_request_unknown_method_falls_back_to_get(): + """Unknown HTTP methods should fall back to a callable (session.get), not a string.""" + client = API() + assert client._dispatch_request("PATCH") == client.session.get