Skip to content

Commit a36d78e

Browse files
committed
chore: fix test nesting
1 parent 8489a4a commit a36d78e

File tree

1 file changed

+36
-38
lines changed

1 file changed

+36
-38
lines changed

test/sync/open_fga_api_test.py

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,47 +1729,45 @@ def test_500_error(self, mock_request):
17291729
mock_request.assert_called()
17301730
self.assertEqual(mock_request.call_count, 1)
17311731

1732-
@patch.object(rest.RESTClientObject, "request")
1733-
def test_500_error_retry(self, mock_request):
1734-
"""
1735-
Test to ensure 5xx retries are handled properly
1736-
"""
1737-
response_body = """
1738-
{
1739-
"code": "internal_error",
1740-
"message": "Internal Server Error"
1741-
}
1742-
"""
1743-
mock_request.side_effect = [
1744-
ServiceException(http_resp=http_mock_response(response_body, 500)),
1745-
ServiceException(http_resp=http_mock_response(response_body, 502)),
1746-
ServiceException(http_resp=http_mock_response(response_body, 503)),
1747-
ServiceException(http_resp=http_mock_response(response_body, 504)),
1748-
mock_response(response_body, 200),
1749-
]
1732+
@patch.object(rest.RESTClientObject, "request")
1733+
def test_500_error_retry(self, mock_request):
1734+
"""Test to ensure 5xx retries are handled properly"""
1735+
response_body = """
1736+
{
1737+
"code": "internal_error",
1738+
"message": "Internal Server Error"
1739+
}
1740+
"""
1741+
mock_request.side_effect = [
1742+
ServiceException(http_resp=http_mock_response(response_body, 500)),
1743+
ServiceException(http_resp=http_mock_response(response_body, 502)),
1744+
ServiceException(http_resp=http_mock_response(response_body, 503)),
1745+
ServiceException(http_resp=http_mock_response(response_body, 504)),
1746+
mock_response(response_body, 200),
1747+
]
17501748

1751-
retry = openfga_sdk.configuration.RetryParams(5, 10)
1752-
configuration = self.configuration
1753-
configuration.store_id = store_id
1754-
configuration.retry_params = retry
1755-
1756-
with ApiClient(configuration) as api_client:
1757-
api_instance = open_fga_api.OpenFgaApi(api_client)
1758-
body = CheckRequest(
1759-
tuple_key=TupleKey(
1760-
object="document:2021-budget",
1761-
relation="reader",
1762-
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
1763-
),
1764-
)
1749+
retry = openfga_sdk.configuration.RetryParams(5, 10)
1750+
configuration = self.configuration
1751+
configuration.store_id = store_id
1752+
configuration.retry_params = retry
17651753

1766-
api_response = api_instance.check(
1767-
body=body,
1768-
)
1754+
with ApiClient(configuration) as api_client:
1755+
api_instance = open_fga_api.OpenFgaApi(api_client)
1756+
body = CheckRequest(
1757+
tuple_key=TupleKey(
1758+
object="document:2021-budget",
1759+
relation="reader",
1760+
user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
1761+
),
1762+
)
17691763

1770-
self.assertIsInstance(api_response, CheckResponse)
1771-
mock_request.assert_called()
1772-
self.assertEqual(mock_request.call_count, 5)
1764+
api_response = api_instance.check(
1765+
body=body,
1766+
)
1767+
1768+
self.assertIsInstance(api_response, CheckResponse)
1769+
mock_request.assert_called()
1770+
self.assertEqual(mock_request.call_count, 5)
17731771

17741772
@patch.object(rest.RESTClientObject, "request")
17751773
def test_501_error_retry(self, mock_request):

0 commit comments

Comments
 (0)