Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/emr/test_list_clusters.py
1569 views
1
# Copyright 2014 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
14
from tests.unit.customizations.emr import EMRBaseAWSCommandParamsTest as \
15
BaseAWSCommandParamsTest
16
from datetime import datetime
17
from time import mktime
18
19
20
class TestListClusters(BaseAWSCommandParamsTest):
21
prefix = 'emr list-clusters '
22
23
def test_list_active_clusters(self):
24
args = '--active'
25
cmdline = self.prefix + args
26
result = {'ClusterStates': ['STARTING',
27
'BOOTSTRAPPING',
28
'RUNNING',
29
'WAITING',
30
'TERMINATING'
31
]
32
}
33
self.assert_params_for_cmd(cmdline, result)
34
35
def test_list_terminated_clusters(self):
36
args = '--terminated'
37
cmdline = self.prefix + args
38
result = {'ClusterStates': ['TERMINATED']}
39
self.assert_params_for_cmd(cmdline, result)
40
41
def test_list_failed_clusters(self):
42
args = '--failed'
43
cmdline = self.prefix + args
44
result = {'ClusterStates': ['TERMINATED_WITH_ERRORS']}
45
self.assert_params_for_cmd(cmdline, result)
46
47
def test_list_multiple_states(self):
48
args = '--cluster-states RUNNING WAITING TERMINATED'
49
cmdline = self.prefix + args
50
result = {'ClusterStates': ['RUNNING', 'WAITING', 'TERMINATED']}
51
self.assert_params_for_cmd(cmdline, result)
52
53
def test_exclusive_states_filters(self):
54
args = '--active --failed'
55
cmdline = self.prefix + args
56
expected_error_msg = (
57
'\naws: error: You can specify only one of the cluster state '
58
'filters: --cluster-states, --active, --terminated, --failed.\n')
59
result = self.run_cmd(cmdline, 255)
60
self.assertEqual(expected_error_msg, result[1])
61
62
args = '--cluster-states STARTING RUNNING --terminated'
63
cmdline = self.prefix + args
64
expected_error_msg = (
65
'\naws: error: You can specify only one of the cluster state '
66
'filters: --cluster-states, --active, --terminated, --failed.\n')
67
result = self.run_cmd(cmdline, 255)
68
self.assertEqual(expected_error_msg, result[1])
69
70
71
if __name__ == "__main__":
72
unittest.main()
73
74