Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't send body for get requests #763

Merged
merged 4 commits into from
May 23, 2023
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
8 changes: 7 additions & 1 deletion meilisearch/_httprequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ def send_request(
self.headers["Content-Type"] = content_type
try:
request_path = self.config.url + "/" + path
if isinstance(body, bytes):
if http_method.__name__ == "get":
request = http_method(
request_path,
timeout=self.config.timeout,
headers=self.headers,
)
elif isinstance(body, bytes):
request = http_method(
request_path,
timeout=self.config.timeout,
Expand Down
2 changes: 1 addition & 1 deletion tests/errors/test_api_error_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_meilisearch_api_error_wrong_master_key():
@patch("requests.post")
def test_meilisearch_api_error_no_code(mock_post):
"""Here to test for regressions related to https://github.com/meilisearch/meilisearch-python/issues/305."""

mock_post.configure_mock(__name__="post")
mock_response = requests.models.Response()
mock_response.status_code = 408
mock_post.return_value = mock_response
Expand Down
1 change: 1 addition & 0 deletions tests/errors/test_communication_error_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

@patch("requests.post")
def test_meilisearch_communication_error_host(mock_post):
mock_post.configure_mock(__name__="post")
mock_post.side_effect = requests.exceptions.ConnectionError()
client = meilisearch.Client("http://wrongurl:1234", MASTER_KEY)
with pytest.raises(MeilisearchCommunicationError):
Expand Down
1 change: 1 addition & 0 deletions tests/errors/test_timeout_error_meilisearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

@patch("requests.get")
def test_client_timeout_error(mock_get):
mock_get.configure_mock(__name__="get")
mock_get.side_effect = requests.exceptions.Timeout()
client = meilisearch.Client(BASE_URL, MASTER_KEY, timeout=1)

Expand Down