Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/integration/test_ec2.py
1566 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
from awscli.testutils import unittest, aws
14
15
16
class TestDescribeInstances(unittest.TestCase):
17
def setUp(self):
18
self.prefix = 'ec2 describe-instances --region us-west-2'
19
20
def test_describe_instances_with_id(self):
21
command = self.prefix + ' --instance-ids malformed-id'
22
result = aws(command)
23
self.assertIn('InvalidInstanceID.Malformed', result.stderr)
24
25
def test_describe_instances_with_filter(self):
26
command = self.prefix + ' --filters Name=instance-id,Values='
27
command += 'malformed-id'
28
result = aws(command)
29
reservations = result.json["Reservations"]
30
self.assertEqual(len(reservations), 0)
31
32
33
class TestDescribeSnapshots(unittest.TestCase):
34
def setUp(self):
35
self.prefix = 'ec2 describe-snapshots --region us-west-2'
36
37
def test_describe_snapshot_with_snapshot_id(self):
38
command = self.prefix + ' --snapshot-ids malformed-id'
39
result = aws(command)
40
self.assertIn('InvalidParameterValue', result.stderr)
41
42
def test_describe_snapshots_with_filter(self):
43
command = self.prefix
44
command += ' --filters Name=snapshot-id,Values=malformed-id'
45
result = aws(command)
46
snapshots = result.json['Snapshots']
47
self.assertEqual(len(snapshots), 0)
48
49
50
class TestDescribeVolumes(unittest.TestCase):
51
def setUp(self):
52
self.prefix = 'ec2 describe-volumes --region us-west-2'
53
54
def test_describe_volumes_with_volume_id(self):
55
command = self.prefix + ' --volume-ids malformed-id'
56
result = aws(command)
57
self.assertIn('InvalidParameterValue', result.stderr)
58
59
def test_describe_volumes_with_filter(self):
60
command = self.prefix
61
command += ' --filters Name=volume-id,Values=malformed-id'
62
result = aws(command)
63
volumes = result.json['Volumes']
64
self.assertEqual(len(volumes), 0)
65
66