"""Integration tests for lambda function.""" import json import boto3 import pytest from tests.consts import config as test_config # noqa class TestSuccessfulCheck: """Test successful check.""" @pytest.fixture def lambda_payload(self): """Fixture for lambda payload.""" data = { 'reports': [ { 'inconsistency_type': 'BAD_LABEL_SOUND_RECORDINGS', 'missing_data': [ { 'table_name': 'track', 'primary_key_name': 'id', 'record_id': 27081010 } ] } ] } return json.dumps(data) @pytest.fixture def lambda_response(self, lambda_payload): """Fixture for lambda invocation response.""" client = boto3.client('lambda', region_name=test_config.AWS_REGION) response = client.invoke( FunctionName=test_config.LAMBDA_NAME, InvocationType='RequestResponse', LogType='None', Payload=lambda_payload, ) return json.loads(response['Payload'].read().decode('utf-8')) def test_successful_invocation(self, lambda_response): """Test successful invocation.""" records_to_sync = lambda_response['Records'] assert len(records_to_sync) == 1 record_sync_data = records_to_sync[0]['kinesis']['data'] assert record_sync_data != ''