Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/ec2/test_describe_volumes.py
1567 views
1
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License"). You
4
# may not use this file except in compliance with the License. A copy of
5
# the License is located at
6
#
7
# http://aws.amazon.com/apache2.0/
8
#
9
# or in the "license" file accompanying this file. This file is
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
# ANY KIND, either express or implied. See the License for the specific
12
# language governing permissions and limitations under the License.
13
import json
14
import shutil
15
16
from awscli.testutils import BaseAWSCommandParamsTest
17
from awscli.testutils import FileCreator
18
19
20
class TestDescribeVolumes(BaseAWSCommandParamsTest):
21
22
prefix = 'ec2 describe-volumes'
23
24
def setUp(self):
25
super(TestDescribeVolumes, self).setUp()
26
self.file_creator = FileCreator()
27
28
def tearDown(self):
29
super(TestDescribeVolumes, self).tearDown()
30
shutil.rmtree(self.file_creator.rootdir)
31
32
def test_max_results_set_by_default(self):
33
command = self.prefix
34
params = {'MaxResults': 1000}
35
self.assert_params_for_cmd(command, params)
36
37
def test_max_results_not_set_with_volume_ids(self):
38
command = self.prefix + ' --volume-ids id-volume'
39
params = {'VolumeIds': ['id-volume']}
40
self.assert_params_for_cmd(command, params)
41
42
def test_max_results_not_set_with_filter(self):
43
command = self.prefix + ' --filters Name=volume-id,Values=id-volume'
44
params = {'Filters': [{'Name': 'volume-id', 'Values': ['id-volume']}]}
45
self.assert_params_for_cmd(command, params)
46
47
def test_max_results_not_overwritten(self):
48
command = self.prefix + ' --max-results 5'
49
params = {'MaxResults': 5}
50
self.assert_params_for_cmd(command, params)
51
52
command = self.prefix + ' --page-size 5'
53
self.assert_params_for_cmd(command, params)
54
55
def test_max_results_with_cli_input_json(self):
56
params = {'VolumeIds': ['vol-12345']}
57
file_path = self.file_creator.create_file(
58
'params.json', json.dumps(params))
59
60
command = self.prefix + ' --cli-input-json file://%s' % file_path
61
self.assert_params_for_cmd(command, params)
62
63