Skip to content

Instantly share code, notes, and snippets.

@smoothml
Created February 23, 2018 09:33
Show Gist options
  • Save smoothml/a9f46399ec78f71721ae033238e9d121 to your computer and use it in GitHub Desktop.
Save smoothml/a9f46399ec78f71721ae033238e9d121 to your computer and use it in GitHub Desktop.
2018-02-23 Serverless computing mocked_requests_get.py
def mocked_requests_get(*args, **kwargs):
class MockResponse:
def __init__(self, json_data, status_code):
self.json_data = json_data
self.status_code = status_code
def json(self):
return self.json_data
if args[0] == "http://api.fixer.io/latest?base=GBP":
return MockResponse(TEST_RESPONSE, 200)
return MockResponse(None, 404)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment