Last active
August 19, 2020 01:52
-
-
Save peacing/0c93004f82a1cf136dadd4f8637a2beb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import pytest | |
from lambda_function import * | |
class MockBotoSession: | |
class Session: | |
def client(self, service_name, region_name): | |
# create a flexible Client class for any boto3 client | |
class Client: | |
def list_crawlers(self): | |
# hardcode the list_crawlers response | |
return {'CrawlerNames': ['crawler_1', 'crawler_2',]} | |
return Client() | |
def test_lambda_handler(monkeypatch): | |
# patch boto session with a mock client | |
monkeypatch.setattr(boto3, 'session', MockBotoSession) | |
response = lambda_handler(event=test_event, context={}) | |
assert response == 'something' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment