"""Integration tests for lambda function.""" import pytest from tests.integration.conftest import dockerized_lambda_api_client, mysqlclient_docker @pytest.mark.jira('ACC-5699') def test_invoke_lambda(basic_headers): """Check ledger_db here.""" dockerized_lambda = dockerized_lambda_api_client(basic_headers) body = { 'abacus_event_id': 1067, 'target_type': 'statement_period', 'target_id': '1', 'event_name': 'apply_royalty_reversal', 'event_date': '1997-07-16T19:20:30.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' cnx = mysqlclient_docker() cursor = cnx.cursor() tables = ['ledger_deposit', 'ledger_account_contract', 'ledger_correction'] for table in tables: cursor.execute('SELECT * FROM {}'.format(table)) cursor.fetchall() rc = cursor.rowcount assert rc > 0 cnx.close()