Skip to content
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
2 changes: 1 addition & 1 deletion okta/api_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ async def get_next(self):
if next_request:
# create new response and update generator values
next_response = OktaAPIResponse(
self._request_executor, req, res_details, resp_body)
self._request_executor, req, res_details, resp_body, self._type)
self._next = next_response._next
# yield next page
yield (next_response.get_body(), None, next_response)
28 changes: 28 additions & 0 deletions tests/unit/test_api_response.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import tests.mocks as mocks
import pytest
import okta.models as models
from okta.client import Client
from okta.request_executor import RequestExecutor

Expand Down Expand Up @@ -44,6 +45,33 @@ async def test_response_pagination_with_next(monkeypatch):
await result.next()


@ pytest.mark.asyncio
async def test_response_pagination_with_next_include_response(monkeypatch):
ssws_client = Client({
"orgUrl": ORG_URL,
"token": API_TOKEN
})

req, error = await ssws_client.get_request_executor()\
.create_request("GET",
GET_USERS_CALL + API_LIMIT,
{},
{})

monkeypatch.setattr(RequestExecutor, 'fire_request',
mocks.mock_GET_HTTP_Client_response_valid_with_next)

resp, error = await ssws_client.get_request_executor().execute(req, models.User)
assert resp._type is models.User
monkeypatch.setattr(RequestExecutor, 'fire_request',
mocks.mock_GET_HTTP_Client_response_valid)
# Check next response has same type as first response and check instance types
n_result, n_error, n_resp = await resp.next(includeResponse=True)
assert n_resp._type is resp._type
assert isinstance(n_result[0], resp._type)
assert error is None and n_error is None


@ pytest.mark.asyncio
async def test_response_pagination_with_next_not_starting_with_api(monkeypatch):
ssws_client = Client(CLIENT_CONFIG)
Expand Down