Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aws
GitHub Repository: aws/aws-cli
Path: blob/develop/tests/unit/customizations/emr/test_command.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
from awscli.testutils import mock
14
15
from tests.unit.customizations.emr import EMRBaseAWSCommandParamsTest as \
16
BaseAWSCommandParamsTest
17
import argparse
18
from awscli.customizations.emr.command import Command
19
20
21
class FakeCommand(Command):
22
23
def _run_main_command(self, parsed_args, parsed_globals):
24
return 0
25
26
27
class TestCommand(BaseAWSCommandParamsTest):
28
29
def test_region(self):
30
def mock_region_side_effect(*args, **kwargs):
31
if args[0] == 'region':
32
return 'eu-central-1'
33
else:
34
return None
35
36
mock_session = mock.Mock()
37
mock_session.get_config_variable.side_effect = mock_region_side_effect
38
mock_session.get_scoped_config.return_value = {}
39
parsed_globals = argparse.Namespace()
40
parsed_globals.region = None
41
mocked_parsed_args = mock.Mock()
42
43
cmd = FakeCommand(mock_session)
44
cmd._run_main(mocked_parsed_args, parsed_globals)
45
46
self.assertEqual(cmd.region, 'eu-central-1')
47
48