Get region from args or kwargs
This commit is contained in:
parent
6ab2f58b21
commit
389939bf8a
@ -417,8 +417,9 @@ class ServerModeMockAWS(BaseMockAWS):
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
def fake_boto3_client(*args, **kwargs):
|
def fake_boto3_client(*args, **kwargs):
|
||||||
service, region = args
|
region = self._get_region(*args, **kwargs)
|
||||||
kwargs["config"] = Config(user_agent_extra="region/" + region)
|
if region:
|
||||||
|
kwargs["config"] = Config(user_agent_extra="region/" + region)
|
||||||
if "endpoint_url" not in kwargs:
|
if "endpoint_url" not in kwargs:
|
||||||
kwargs["endpoint_url"] = "http://localhost:5000"
|
kwargs["endpoint_url"] = "http://localhost:5000"
|
||||||
return real_boto3_client(*args, **kwargs)
|
return real_boto3_client(*args, **kwargs)
|
||||||
@ -466,6 +467,14 @@ class ServerModeMockAWS(BaseMockAWS):
|
|||||||
if six.PY2:
|
if six.PY2:
|
||||||
self._httplib_patcher.start()
|
self._httplib_patcher.start()
|
||||||
|
|
||||||
|
def _get_region(self, *args, **kwargs):
|
||||||
|
if "region_name" in kwargs:
|
||||||
|
return kwargs["region_name"]
|
||||||
|
if type(args) == tuple:
|
||||||
|
service, region = args
|
||||||
|
return region
|
||||||
|
return None
|
||||||
|
|
||||||
def disable_patching(self):
|
def disable_patching(self):
|
||||||
if self._client_patcher:
|
if self._client_patcher:
|
||||||
self._client_patcher.stop()
|
self._client_patcher.stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user