Path: blob/develop/tests/unit/customizations/configure/__init__.py
1569 views
# Copyright 2015 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.12from botocore.exceptions import ProfileNotFound131415class FakeSession(object):1617def __init__(self, all_variables, profile_does_not_exist=False,18config_file_vars=None, environment_vars=None,19credentials=None, profile=None):20self.variables = all_variables21self.profile_does_not_exist = profile_does_not_exist22self.config = {}23if config_file_vars is None:24config_file_vars = {}25self.config_file_vars = config_file_vars26if environment_vars is None:27environment_vars = {}28self.environment_vars = environment_vars29self._credentials = credentials30self.profile = profile3132def get_credentials(self):33return self._credentials3435def get_scoped_config(self):36if self.profile_does_not_exist:37raise ProfileNotFound(profile='foo')38return self.config3940def get_config_variable(self, name, methods=None):41if name == 'credentials_file':42# The credentials_file var doesn't require a43# profile to exist.44return '~/fake_credentials_filename'45if self.profile_does_not_exist and not name == 'config_file':46raise ProfileNotFound(profile='foo')47if methods is not None:48if 'env' in methods:49return self.environment_vars.get(name)50elif 'config' in methods:51return self.config_file_vars.get(name)52else:53return self.variables.get(name)5455def emit(self, event_name, **kwargs):56pass5758def emit_first_non_none_response(self, *args, **kwargs):59pass6061def _build_profile_map(self):62if self.full_config is None:63return None64return self.full_config['profiles']656667