11import mock
22import pytest
3+ from botocore .session import Session
34from awsshell .utils import FileReadError
45from awsshell .wizard import stage_error_handler
56from awsshell .interaction import InteractionException
@@ -138,7 +139,8 @@ def test_static_retrieval_with_query(wizard_spec, loader):
138139
139140def test_request_retrieval (wizard_spec_request ):
140141 # Tests that retrieval requests are parsed and call the correct operation
141- mock_session = mock .Mock ()
142+ mock_session = mock .Mock (spec = Session )
143+ mock_session .create_client .return_value .can_paginate .return_value = False
142144 mock_request = mock_session .create_client .return_value .create_rest_api
143145 mock_request .return_value = {'id' : 'api id' , 'name' : 'random name' }
144146
@@ -148,6 +150,23 @@ def test_request_retrieval(wizard_spec_request):
148150 mock_request .assert_called_once_with (param = 'value' , name = 'new api name' )
149151
150152
153+ def test_request_retrieval_paginate (wizard_spec_request ):
154+ # Tests that retrieval requests are parsed and call the correct operation
155+ mock_session = mock .Mock (spec = Session )
156+ mock_client = mock_session .create_client .return_value
157+ mock_client .can_paginate .return_value = True
158+ mock_paginator = mock_client .get_paginator .return_value
159+ mock_iterator = mock_paginator .paginate .return_value
160+ result = {'id' : 'api id' , 'name' : 'random name' }
161+ mock_iterator .build_full_result .return_value = result
162+ paginate = mock_paginator .paginate
163+
164+ loader = WizardLoader (mock_session )
165+ wizard = loader .create_wizard (wizard_spec_request )
166+ wizard .execute ()
167+ paginate .assert_called_once_with (param = 'value' , name = 'new api name' )
168+
169+
151170def test_next_stage_resolution (wizard_spec , loader ):
152171 # Test that the stage can resolve the next stage from env
153172 wizard_spec ['Stages' ][0 ]['Retrieval' ]['Path' ] = '[0]'
0 commit comments