Skip to content

Commit

Permalink
Merge pull request #2510 from JordonPhillips/ec2thing
Browse files Browse the repository at this point in the history
Fix ec2 pagination bug
  • Loading branch information
JordonPhillips authored Mar 28, 2017
2 parents 6d6e52a + fd40a77 commit 156f4a7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
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

0 comments on commit 156f4a7

Please sign in to comment.