"""Integration tests for lambda function.""" import boto3 import pytest from conftest import dockerized_lambda_api_client @pytest.mark.jira('ACC-9822') def test_invoke_lambda(basic_headers): """Assert lambda action.""" s3_client = boto3.client('s3') bucket = 'qa-abacus-adjustments' key = '1/test-adjustment.json.gz' # Delete the file if it exists prior to the test s3_client.delete_object(Bucket=bucket, Key=key) # Verify the file is absent before the test with pytest.raises(s3_client.exceptions.ClientError) as exc_info: s3_client.head_object(Bucket=bucket, Key=key) assert exc_info.value.response['Error']['Code'] == '404' dockerized_lambda = dockerized_lambda_api_client(basic_headers) body = { 'abacus_event_id': 1, 'target_type': 'statement_period_adjustment_file', 'target_id': '1', 'event_name': 'generate_flowthrough_adjustments', 'event_date': '2026-02-13T11:20:35.45+01:00', 'statement_period_id': 325, } res = dockerized_lambda.post_lambda('2015-03-31', body) assert res.status_code == 200 assert res.json() == {'status': 'OK'} # Verify the file is present after the test response = s3_client.head_object(Bucket=bucket, Key=key) assert response['ResponseMetadata']['HTTPStatusCode'] == 200