Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion datamaxi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading