-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from groveco/retry-behaviour
Retry behaviour
- Loading branch information
Showing
6 changed files
with
255 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.0.5 | ||
0.0.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
import requests | ||
import pytest | ||
from shopify_client import ShopifyClient | ||
from tests.conftest import CopyingMock | ||
|
||
|
||
def test_client_initialization(shopify_client): | ||
assert shopify_client.headers["X-Shopify-Access-Token"] == "test-token" | ||
assert shopify_client.headers["Content-Type"] == "application/json" | ||
|
||
|
||
def test_request_with_versioning(shopify_client, mocker): | ||
mock_request = mocker.patch("requests.Session.request", return_value=mocker.Mock(status_code=200, json=lambda: {"result": "success"})) | ||
mock_request = mocker.patch( | ||
"requests.Session.request", | ||
return_value=mocker.Mock(status_code=200, json=lambda: {"result": "success"}), | ||
) | ||
response = shopify_client.request("GET", "products.json") | ||
assert response.json() == {"result": "success"} | ||
mock_request.assert_called_once_with( | ||
"GET", | ||
"https://test-shop.myshopify.com/admin/api/2024-10/products.json" | ||
"GET", "https://test-shop.myshopify.com/admin/api/2024-10/products.json" | ||
) | ||
|
||
|
||
def test_parse_response_success(shopify_client, mocker): | ||
mock_response = mocker.Mock(status_code=200, json=lambda: {"key": "value"}) | ||
parsed = shopify_client.parse_response(mock_response) | ||
assert parsed == {"key": "value"} | ||
|
||
|
||
def test_parse_response_error(shopify_client, mocker): | ||
mock_response = mocker.Mock(status_code=404, text="Not Found") | ||
mock_response.raise_for_status.side_effect = requests.exceptions.HTTPError("Not Found") | ||
|
||
mock_response.raise_for_status.side_effect = requests.exceptions.HTTPError( | ||
"Not Found" | ||
) | ||
|
||
with pytest.raises(requests.exceptions.HTTPError): | ||
shopify_client.parse_response(mock_response) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.