Skip to content

Commit 6ac7084

Browse files
committed
changes requested as per soulpancake and copilot
1 parent 5da12ec commit 6ac7084

File tree

4 files changed

+60
-4
lines changed

4 files changed

+60
-4
lines changed

openfga_sdk/client/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ def set_heading_if_not_set(
103103

104104

105105
def options_to_kwargs(
106-
options: dict[str, int | str | dict[str, int | str]] | None = None,
107-
) -> dict[str, int | str | dict[str, int | str]]:
106+
options: dict[str, int | str | bool | dict[str, int | str]] | None = None,
107+
) -> dict[str, int | str | bool | dict[str, int | str]]:
108108
"""
109109
Return kwargs with continuation_token and page_size
110110
"""
@@ -120,6 +120,8 @@ def options_to_kwargs(
120120
kwargs["_headers"] = options["headers"]
121121
if options.get("retry_params"):
122122
kwargs["_retry_params"] = options["retry_params"]
123+
if options.get("async_req") is not None:
124+
kwargs["async_req"] = options["async_req"]
123125
return kwargs
124126

125127

openfga_sdk/sync/client/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def set_heading_if_not_set(
104104

105105

106106
def options_to_kwargs(
107-
options: dict[str, int | str | dict[str, int | str]] | None = None,
108-
) -> dict[str, int | str | dict[str, int | str]]:
107+
options: dict[str, int | str | bool | dict[str, int | str]] | None = None,
108+
) -> dict[str, int | str | bool | dict[str, int | str]]:
109109
"""
110110
Return kwargs with continuation_token and page_size
111111
"""

test/client/client_test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,33 @@ async def test_list_stores_with_name(self, mock_request):
244244
_request_timeout=ANY,
245245
)
246246

247+
@patch.object(rest.RESTClientObject, "request")
248+
async def test_list_stores_with_async_req(self, mock_request):
249+
"""Test that async_req option is correctly propagated to the API call"""
250+
response_body = json.dumps(
251+
{
252+
"stores": [],
253+
"continuation_token": "",
254+
}
255+
)
256+
257+
mock_request.return_value = mock_response(response_body, 200)
258+
configuration = self.configuration
259+
260+
async with OpenFgaClient(configuration) as api_client:
261+
with patch.object(
262+
api_client._api, "list_stores", wraps=api_client._api.list_stores
263+
) as mock_api_list_stores:
264+
await api_client.list_stores(
265+
options={
266+
"async_req": True,
267+
}
268+
)
269+
270+
mock_api_list_stores.assert_called_once_with(
271+
async_req=True,
272+
)
273+
247274
@patch.object(rest.RESTClientObject, "request")
248275
async def test_create_store(self, mock_request):
249276
"""Test case for create_store

test/sync/client/client_test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,33 @@ def test_list_stores_with_name(self, mock_request):
243243
_request_timeout=ANY,
244244
)
245245

246+
@patch.object(rest.RESTClientObject, "request")
247+
def test_list_stores_with_async_req(self, mock_request):
248+
"""Test that async_req option is correctly propagated to the API call"""
249+
response_body = json.dumps(
250+
{
251+
"stores": [],
252+
"continuation_token": "",
253+
}
254+
)
255+
256+
mock_request.return_value = mock_response(response_body, 200)
257+
configuration = self.configuration
258+
259+
with OpenFgaClient(configuration) as api_client:
260+
with patch.object(
261+
api_client._api, "list_stores", wraps=api_client._api.list_stores
262+
) as mock_api_list_stores:
263+
api_client.list_stores(
264+
options={
265+
"async_req": True,
266+
}
267+
)
268+
269+
mock_api_list_stores.assert_called_once_with(
270+
async_req=True,
271+
)
272+
246273
@patch.object(rest.RESTClientObject, "request")
247274
def test_create_store(self, mock_request):
248275
"""Test case for create_store

0 commit comments

Comments
 (0)