"""Lambda test module.""" import boto3 from moto import mock_aws from src.app import handler @mock_aws def test_handler_missing_keys_permanent_failure(): """Test that the handler returns the correct response when the job is missing keys.""" # Setup mock S3 s3_client = boto3.client('s3') s3_client.create_bucket(Bucket='test-bucket') event = dict( invocationId='123', invocationSchemaVersion='2.0', job=dict( id='123', userArguments=dict( destination_bucket='test-bucket', destination_prefix='test-prefix', ), ), tasks=[ dict( taskId='123', s3Bucket='test-bucket', s3Key='test-key', ), ], ) context = {} response = handler(event, context) assert response['treatMissingKeysAs'] == 'PermanentFailure' assert response['invocationId'] == '123' assert response['invocationSchemaVersion'] == '2.0' assert len(response['results']) == 1 assert response['results'][0]['taskId'] == '123' assert response['results'][0]['resultCode'] == 'PermanentFailure'