def test_raises_for_missing_file(self): os.environ['AWS_CONFIG_FILE'] = uuid.uuid4().hex with mock.patch( 'tornado_aws.config._request_region_from_instance') as region: region.side_effect = OSError with self.assertRaises(exceptions.ConfigNotFound): config.get_region('default')
def test_missing_profile_value(self): ini_values = {'profile foo': {'region': uuid.uuid4().hex}} with tempfile.NamedTemporaryFile() as handle: handle.write(utils.build_ini(ini_values)) handle.flush() os.environ['AWS_CONFIG_FILE'] = handle.name with self.assertRaises(exceptions.NoProfileError): config.get_region('testing')
def test_parsing_file(self): expectation = {'default': {'region': uuid.uuid4().hex}} with tempfile.NamedTemporaryFile() as handle: handle.write(utils.build_ini(expectation)) handle.flush() os.environ['AWS_CONFIG_FILE'] = handle.name value = config.get_region('default') self.assertEqual(expectation['default']['region'], value)
def __init__(self, service, profile=None, region=None, access_key=None, secret_key=None, endpoint=None): self._service = service self._profile = profile or os.getenv('AWS_DEFAULT_PROFILE', 'default') self._region = region or config.get_region(profile) self._client = self._get_client_adapter() self._auth_config = config.Authorization(self._profile, access_key, secret_key, self._client) self._endpoint_url = self._endpoint(endpoint) self._host = self._hostname(self._endpoint_url)
def test_parsing_file(self): expectation = { 'default': { 'region': uuid.uuid4().hex } } with tempfile.NamedTemporaryFile() as handle: handle.write(utils.build_ini(expectation)) handle.flush() os.environ['AWS_CONFIG_FILE'] = handle.name value = config.get_region('default') self.assertEqual(expectation['default']['region'], value)
def __init__(self, service, profile=None, region=None, access_key=None, secret_key=None, endpoint=None): self._client = self._get_client_adapter() self._service = service self._profile = profile or os.getenv('AWS_DEFAULT_PROFILE', 'default') self._region = region or config.get_region(self._profile) self._auth_config = config.Authorization(self._profile, access_key, secret_key, self._client) self._endpoint_url = self._endpoint(endpoint) self._host = self._hostname(self._endpoint_url)