Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/functional/ec2/test_modify_image_attribute.py
1567 views
1
#!/usr/bin/env python
2
# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
#
4
# Licensed under the Apache License, Version 2.0 (the "License"). You
5
# may not use this file except in compliance with the License. A copy of
6
# the License is located at
7
#
8
# http://aws.amazon.com/apache2.0/
9
#
10
# or in the "license" file accompanying this file. This file is
11
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
12
# ANY KIND, either express or implied. See the License for the specific
13
# language governing permissions and limitations under the License.
14
from awscli.testutils import BaseAWSCommandParamsTest
15
16
17
class TestModifyInstanceAttribute(BaseAWSCommandParamsTest):
18
19
prefix = 'ec2 modify-image-attribute'
20
21
def test_one(self):
22
cmdline = self.prefix
23
cmdline += ' --image-id ami-d00dbeef'
24
cmdline += ' --operation-type add'
25
cmdline += ' --user-ids 0123456789012'
26
result = {'ImageId': 'ami-d00dbeef',
27
'OperationType': 'add',
28
'UserIds': ['0123456789012']}
29
self.assert_params_for_cmd(cmdline, result)
30
31
def test_two(self):
32
cmdline = self.prefix
33
cmdline += ' --image-id ami-d00dbeef'
34
cmdline += (' --launch-permission {"Add":[{"UserId":"123456789012"}],'
35
'"Remove":[{"Group":"all"}]}')
36
result = {
37
'ImageId': 'ami-d00dbeef',
38
'LaunchPermission': {
39
'Add': [{'UserId': '123456789012'}],
40
'Remove': [{'Group': 'all'}],
41
}
42
}
43
self.assert_params_for_cmd(cmdline, result)
44
45
def test_assert_error_in_bad_json_path(self):
46
cmdline = self.prefix
47
cmdline += ' --image-id ami-d00dbeef'
48
cmdline += ' --launch-permission THISISNOTJSON'
49
# The arg name should be in the error message.
50
self.assert_params_for_cmd(cmdline, expected_rc=255,
51
stderr_contains='launch-permission')
52
53
54
if __name__ == "__main__":
55
unittest.main()
56
57