Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/emr/__init__.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 awscli.customizations.emr import exceptions
15
from awscli.customizations.emr.configutils import ConfigWriter
16
from awscli.customizations.preview import mark_as_preview
17
from awscli.testutils import BaseAWSCommandParamsTest
18
from awscli.testutils import mock
19
20
class EMRBaseAWSCommandParamsTest(BaseAWSCommandParamsTest):
21
22
def setUp(self):
23
super(EMRBaseAWSCommandParamsTest, self).setUp()
24
25
# Do not use any emr-specific configs for the test cases
26
self.get_scoped_config_mock = mock.Mock()
27
self.set_configs({})
28
29
# Do not write or update the config (~/.aws/config) file
30
self.patcher_update_config = mock.patch(
31
'awscli.customizations.emr.configutils.ConfigWriter.update_config')
32
self.mock_update_config = self.patcher_update_config.start()
33
34
def set_configs(self, configs):
35
self.driver.session.get_scoped_config = self.get_scoped_config_mock
36
self.get_scoped_config_mock.return_value = {'emr': configs}
37
38
def tearDown(self):
39
super(EMRBaseAWSCommandParamsTest, self).tearDown()
40
self.patcher_update_config.stop()
41
42
def assert_error_msg(self, cmd,
43
exception_class_name, error_msg_kwargs={}):
44
exception_class = getattr(exceptions, exception_class_name)
45
error_msg = "\n%s\n" % exception_class.fmt.format(**error_msg_kwargs)
46
result = self.run_cmd(cmd, 255)
47
self.assertEqual(error_msg, result[1])
48
49