"""Lambda test module.""" import mock import consts # noqa import index # noqa @mock.patch('s3.delete_key') @mock.patch('streams_totals.load') @mock.patch('util.object_is_file') @mock.patch('s3.key_exists') @mock.patch('util.extract_triggered_key') def test_handler( extract_triggered_key_mock, key_exists_mock, object_is_file_mock, load_mock, delete_key_mock): """Test handler function.""" # mocking test_bucket = 'test_bucket' test_key = 'test_key' event_mock = {'Records': [{ 's3': {'bucket': {'name': test_bucket}, 'object': {'key': test_key}} }]} extract_triggered_key_mock.return_value = (test_bucket, test_key) key_exists_mock.return_value = True object_is_file_mock.return_value = True # test function call index.handler(event_mock, None) # checking s3_url = 's3://{bucket}/{key}'.format(bucket=test_bucket, key=test_key) load_mock.assert_called_once_with(s3_url, consts.VENDOR) delete_key_mock.assert_called_once_with(test_bucket, test_key)