"""Integration tests for lambda function.""" import operator import pytest from tests.integration.conftest import dockerized_lambda_api_client from tests.integration.utils.db_helper import check_db_empty @pytest.mark.jira('ACC-4152') def test_invoke_lambda( basic_headers, create_art_rel_currencies, create_art_rel_vendor_contract, currency_fixture, create_distribution_type, distribution_type_fixture, create_vendor_contract_distribution_type, ): """Lambda integration scenario.""" check_db_empty(operator.le, 'vendor_contract') check_db_empty(operator.le, 'vendor_contract_distribution_type') dockerized_lambda = dockerized_lambda_api_client(basic_headers) body = { 'abacus_event_id': 1, 'target_type': 'contract', 'target_id': '1', 'event_name': 'legacy_sync_contract', 'event_date': '2021-07-11T11:20:35.45+01:00', } res = dockerized_lambda.post_lambda('2015-03-31', body) assert res.status_code == 200 assert 'status' in res.json(), ( f'error type was: {res.json()["errorType"]}, ' f'error message was: {res.json()["errorMessage"]}' ) assert res.json()['status'] == 'OK' check_db_empty(operator.gt, 'vendor_contract') check_db_empty(operator.gt, 'vendor_contract_distribution_type')