Path: blob/develop/tests/functional/ec2/test_describe_volumes.py
1567 views
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12import json13import shutil1415from awscli.testutils import BaseAWSCommandParamsTest16from awscli.testutils import FileCreator171819class TestDescribeVolumes(BaseAWSCommandParamsTest):2021prefix = 'ec2 describe-volumes'2223def setUp(self):24super(TestDescribeVolumes, self).setUp()25self.file_creator = FileCreator()2627def tearDown(self):28super(TestDescribeVolumes, self).tearDown()29shutil.rmtree(self.file_creator.rootdir)3031def test_max_results_set_by_default(self):32command = self.prefix33params = {'MaxResults': 1000}34self.assert_params_for_cmd(command, params)3536def test_max_results_not_set_with_volume_ids(self):37command = self.prefix + ' --volume-ids id-volume'38params = {'VolumeIds': ['id-volume']}39self.assert_params_for_cmd(command, params)4041def test_max_results_not_set_with_filter(self):42command = self.prefix + ' --filters Name=volume-id,Values=id-volume'43params = {'Filters': [{'Name': 'volume-id', 'Values': ['id-volume']}]}44self.assert_params_for_cmd(command, params)4546def test_max_results_not_overwritten(self):47command = self.prefix + ' --max-results 5'48params = {'MaxResults': 5}49self.assert_params_for_cmd(command, params)5051command = self.prefix + ' --page-size 5'52self.assert_params_for_cmd(command, params)5354def test_max_results_with_cli_input_json(self):55params = {'VolumeIds': ['vol-12345']}56file_path = self.file_creator.create_file(57'params.json', json.dumps(params))5859command = self.prefix + ' --cli-input-json file://%s' % file_path60self.assert_params_for_cmd(command, params)616263