Skip to content

Commit a6b9e33

Browse files
Merge pull request #438 from comrumino/master
Fixed #435: added data_type parameter for OktaAPIResponse
2 parents 5f76a44 + be80c47 commit a6b9e33

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

okta/api_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ async def get_next(self):
180180
if next_request:
181181
# create new response and update generator values
182182
next_response = OktaAPIResponse(
183-
self._request_executor, req, res_details, resp_body)
183+
self._request_executor, req, res_details, resp_body, self._type)
184184
self._next = next_response._next
185185
# yield next page
186186
yield (next_response.get_body(), None, next_response)

tests/unit/test_api_response.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import tests.mocks as mocks
22
import pytest
3+
import okta.models as models
34
from okta.client import Client
45
from okta.request_executor import RequestExecutor
56

@@ -44,6 +45,33 @@ async def test_response_pagination_with_next(monkeypatch):
4445
await result.next()
4546

4647

48+
@ pytest.mark.asyncio
49+
async def test_response_pagination_with_next_include_response(monkeypatch):
50+
ssws_client = Client({
51+
"orgUrl": ORG_URL,
52+
"token": API_TOKEN
53+
})
54+
55+
req, error = await ssws_client.get_request_executor()\
56+
.create_request("GET",
57+
GET_USERS_CALL + API_LIMIT,
58+
{},
59+
{})
60+
61+
monkeypatch.setattr(RequestExecutor, 'fire_request',
62+
mocks.mock_GET_HTTP_Client_response_valid_with_next)
63+
64+
resp, error = await ssws_client.get_request_executor().execute(req, models.User)
65+
assert resp._type is models.User
66+
monkeypatch.setattr(RequestExecutor, 'fire_request',
67+
mocks.mock_GET_HTTP_Client_response_valid)
68+
# Check next response has same type as first response and check instance types
69+
n_result, n_error, n_resp = await resp.next(includeResponse=True)
70+
assert n_resp._type is resp._type
71+
assert isinstance(n_result[0], resp._type)
72+
assert error is None and n_error is None
73+
74+
4775
@ pytest.mark.asyncio
4876
async def test_response_pagination_with_next_not_starting_with_api(monkeypatch):
4977
ssws_client = Client(CLIENT_CONFIG)

0 commit comments

Comments
 (0)