Skip to content

Commit

Permalink
Try to get tests running
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenz Hufnagel committed Oct 29, 2018
1 parent fd4e524 commit b20e190
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions moto/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def __call__(self, event_name, request, **kwargs):
class BotocoreEventMockAWS(BaseMockAWS):
def reset(self):
botocore_stubber.reset()
responses_mock.reset()

def enable_patching(self):
botocore_stubber.enabled = True
Expand All @@ -312,10 +313,32 @@ def enable_patching(self):
pattern = re.compile(key)
botocore_stubber.register_response(method, pattern, value)

if not hasattr(responses_mock, '_patcher') or not hasattr(responses_mock._patcher, 'target'):
responses_mock.start()

for method in RESPONSES_METHODS:
# for backend in default_backends.values():
for backend in self.backends_for_urls.values():
for key, value in backend.urls.items():
responses_mock.add(
CallbackResponse(
method=method,
url=re.compile(key),
callback=convert_flask_to_responses_response(value),
stream=True,
match_querystring=False,
)
)

def disable_patching(self):
botocore_stubber.enabled = False
self.reset()

try:
responses_mock.stop()
except RuntimeError:
pass


MockAWS = BotocoreEventMockAWS

Expand Down

0 comments on commit b20e190

Please sign in to comment.