Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ec2 pagination bug #2510

Merged
merged 1 commit into from
Mar 28, 2017
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
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-ec2-77933.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"description": "Fixed a bug causing some ec2 commands to fail with an invalid parameter combination error when arguments were supplied via --cli-input-json. Resolves `#2452 <https://github.com/aws/aws-cli/issues/2452>`__",
"category": "ec2",
"type": "bugfix"
}
2 changes: 1 addition & 1 deletion awscli/customizations/cliinputjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __init__(self, session):

def _register_argument_action(self):
self._session.register(
'calling-command', self.add_to_call_parameters)
'calling-command.*', self.add_to_call_parameters)
super(CliInputJSONArgument, self)._register_argument_action()

def add_to_call_parameters(self, call_parameters, parsed_args,
Expand Down
20 changes: 20 additions & 0 deletions tests/functional/ec2/test_describe_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,25 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
import json
import shutil

from awscli.testutils import BaseAWSCommandParamsTest
from awscli.testutils import FileCreator


class TestDescribeVolumes(BaseAWSCommandParamsTest):

prefix = 'ec2 describe-volumes'

def setUp(self):
super(TestDescribeVolumes, self).setUp()
self.file_creator = FileCreator()

def tearDown(self):
super(TestDescribeVolumes, self).tearDown()
shutil.rmtree(self.file_creator.rootdir)

def test_max_results_set_by_default(self):
command = self.prefix
params = {'MaxResults': 1000}
Expand All @@ -39,3 +51,11 @@ def test_max_results_not_overwritten(self):

command = self.prefix + ' --page-size 5'
self.assert_params_for_cmd(command, params)

def test_max_results_with_cli_input_json(self):
params = {'VolumeIds': ['vol-12345']}
file_path = self.file_creator.create_file(
'params.json', json.dumps(params))

command = self.prefix + ' --cli-input-json file://%s' % file_path
self.assert_params_for_cmd(command, params)
2 changes: 1 addition & 1 deletion tests/unit/customizations/test_cliinputjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def tearDown(self):

def test_register_argument_action(self):
register_args = self.session.register.call_args_list
self.assertEqual(register_args[0][0][0], 'calling-command')
self.assertEqual(register_args[0][0][0], 'calling-command.*')
self.assertEqual(register_args[0][0][1],
self.argument.add_to_call_parameters)

Expand Down