Path: blob/develop/tests/unit/customizations/emr/test_list_clusters.py
1569 views
# Copyright 2014 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.1213from tests.unit.customizations.emr import EMRBaseAWSCommandParamsTest as \14BaseAWSCommandParamsTest15from datetime import datetime16from time import mktime171819class TestListClusters(BaseAWSCommandParamsTest):20prefix = 'emr list-clusters '2122def test_list_active_clusters(self):23args = '--active'24cmdline = self.prefix + args25result = {'ClusterStates': ['STARTING',26'BOOTSTRAPPING',27'RUNNING',28'WAITING',29'TERMINATING'30]31}32self.assert_params_for_cmd(cmdline, result)3334def test_list_terminated_clusters(self):35args = '--terminated'36cmdline = self.prefix + args37result = {'ClusterStates': ['TERMINATED']}38self.assert_params_for_cmd(cmdline, result)3940def test_list_failed_clusters(self):41args = '--failed'42cmdline = self.prefix + args43result = {'ClusterStates': ['TERMINATED_WITH_ERRORS']}44self.assert_params_for_cmd(cmdline, result)4546def test_list_multiple_states(self):47args = '--cluster-states RUNNING WAITING TERMINATED'48cmdline = self.prefix + args49result = {'ClusterStates': ['RUNNING', 'WAITING', 'TERMINATED']}50self.assert_params_for_cmd(cmdline, result)5152def test_exclusive_states_filters(self):53args = '--active --failed'54cmdline = self.prefix + args55expected_error_msg = (56'\naws: error: You can specify only one of the cluster state '57'filters: --cluster-states, --active, --terminated, --failed.\n')58result = self.run_cmd(cmdline, 255)59self.assertEqual(expected_error_msg, result[1])6061args = '--cluster-states STARTING RUNNING --terminated'62cmdline = self.prefix + args63expected_error_msg = (64'\naws: error: You can specify only one of the cluster state '65'filters: --cluster-states, --active, --terminated, --failed.\n')66result = self.run_cmd(cmdline, 255)67self.assertEqual(expected_error_msg, result[1])686970if __name__ == "__main__":71unittest.main()727374