"""Integration tests for ows-accounting: reports -> get reports.""" import pytest from tests.integration import conftest from tests.integration.conftest import label_18805, label_7482, \ subaccount_13823, user_headers from tests.testutils.dynamodb import dynamodb_helper @pytest.mark.parametrize('user, periods, postfix', [ # periods here should be static and be different from the ones used for # POST /report scenarios since cleanup logic of POST /report scenarios # causes conflicts for GET /reports (label_7482(), '226,227,228', 'L'), (subaccount_13823(), '229', 'S'), (label_18805(), '230', 'L')]) def test_get_reports(user, periods, postfix): """GET /reports gives requested reports history for quarterly user, monthly user and subaccount""" params = {'periods': periods} test_user = user headers = user_headers( test_user['user_type'], test_user['id'], test_user['vend_contact_id']) ows_accounting_client = conftest.ows_accounting_api_client(headers) results = ows_accounting_client.get_reports(params) json_results = results.json() assert results.status_code == 200, \ 'Result of call was {}, expected 200.'.format(results.status_code) items_from_db = dynamodb_helper.user_statement_export_items('{}{}'.format( test_user['id'], postfix), params['periods']) expected_reports = list( map(lambda i: i['user_params'], items_from_db)) actual_reports = list( map(lambda i: i['user_params'], json_results['items'])) assert set(expected_reports) == set(actual_reports)