"""Integration tests for reference flowthrough calculations endpoints.""" import pytest from tests.integration.conftest import ows_abacus_contract_api_client @pytest.mark.jira('PLATFORM-4504') def test_get_reference_flowthrough_calculation_by_id_authorization( auth_headers: dict[str, str], unauthorized_headers: dict[str, str], create_reference_flowthrough_calculation: None, ) -> None: """Test authorization for getting reference flowthrough calculation by id.""" ows_abacus_contract_client = ows_abacus_contract_api_client(auth_headers) # id (and name) defined in create_reference_flowthrough_calculation fixture res = ows_abacus_contract_client.get_reference_flowthrough_calculations_by_id(1) assert res.status_code == 200 assert res.json()['flowthrough_calculation_name'] == \ 'integration_tests_flowthrough_calculation' # Unauthorized access ows_abacus_contract_client = ows_abacus_contract_api_client(unauthorized_headers) res = ows_abacus_contract_client.get_reference_flowthrough_calculations_by_id(1) assert res.status_code == 403 assert res.json()['message'] == 'User is forbidden' @pytest.mark.jira('ACC-8250') def test_get_reference_flowthrough_calculations( basic_headers, create_reference_flowthrough_calculation ): """GET /reference-flowthrough-calculations endpoints .""" ows_abacus_contract_client = ows_abacus_contract_api_client(basic_headers) res_get = ows_abacus_contract_client.get_reference_flowthrough_calculations() assert res_get.status_code == 200 assert len(res_get.json()['items']) > 0 assert res_get.json()['total_count'] > 0 assert res_get.json()['items'][0]['flowthrough_calculation_name'] == \ 'integration_tests_flowthrough_calculation' res_get = ows_abacus_contract_client.get_reference_flowthrough_calculations_by_id(1) assert res_get.status_code == 200 assert res_get.json()['flowthrough_calculation_name'] == \ 'integration_tests_flowthrough_calculation'