"""Integration tests for reference-transaction-type-group endpoints.""" import pytest from tests.integration import conftest @pytest.mark.jira('PLATFORM-4456') def test_get_transaction_types_groups_and_transaction_types( auth_headers: dict[str, str] ) -> None: """Test getting transaction type groups and transaction types.""" client = conftest.ows_abacus_contract_api_client(auth_headers) res = client.get_transaction_types_groups_and_transaction_types() assert res.status_code == 200 # Just one entry that we expect to be in the list expected_entry = { 'reference_transaction_type_group_transaction_type_id': 1, 'reference_transaction_type_group_id': 1, 'reference_transaction_type_id': 1, 'reference_transaction_type_group_admin': 'contract_admin', } assert expected_entry in res.json() @pytest.mark.jira('PLATFORM-4456') def test_get_transaction_types_groups_and_transaction_types_forbidden( unauthorized_headers: dict[str, str], ) -> None: """Test getting transaction type groups and transaction types with forbidden access.""" # noqa client = conftest.ows_abacus_contract_api_client(unauthorized_headers) res = client.get_transaction_types_groups_and_transaction_types() assert res.status_code == 403 assert res.json()['message'] == 'User is forbidden' @pytest.mark.jira('PLATFORM-4456') def test_get_transaction_type_groups(auth_headers: dict[str, str]) -> None: """Test getting transaction type groups.""" client = conftest.ows_abacus_contract_api_client(auth_headers) res = client.get_transaction_type_groups() assert res.status_code == 200 # Just one entry that we expect to be in the list expected_entry = { 'reference_transaction_type_group_id': 1, 'transaction_type_group_name': 'Digital Distribution Streaming', } assert expected_entry in res.json() @pytest.mark.jira('PLATFORM-4456') def test_get_transaction_type_groups_forbidden( unauthorized_headers: dict[str, str], ) -> None: """Test getting transaction type groups with forbidden access.""" client = conftest.ows_abacus_contract_api_client(unauthorized_headers) res = client.get_transaction_type_groups() assert res.status_code == 403 assert res.json()['message'] == 'User is forbidden' @pytest.mark.jira('ACC-7003') def test_transaction_type_groups_by_admin(basic_headers): """GET /reference-transaction-type-group/group-admin/.""" ows_abacus_contract_client = conftest.ows_abacus_contract_api_client(basic_headers) res_get = \ ows_abacus_contract_client.get_transaction_type_groups_by_group_admin( 'contract_admin' ) assert res_get.status_code == 200 assert len(res_get.json()) > 0 for i in res_get.json(): assert 'reference_transaction_type_group_id' in i assert 'transaction_type_group_name' in i @pytest.mark.jira('PLATFORM-4456') def test_get_transaction_type_groups_by_admin_authorization( auth_headers: dict[str, str], unauthorized_headers: dict[str, str], ) -> None: """Test authorization for getting transaction type groups by group admin.""" client = conftest.ows_abacus_contract_api_client(auth_headers) res = client.get_transaction_type_groups_by_group_admin('contract_admin') assert res.status_code == 200 assert len(res.json()) > 0 client = conftest.ows_abacus_contract_api_client(unauthorized_headers) res = client.get_transaction_type_groups_by_group_admin('contract_admin') assert res.status_code == 403 assert res.json()['message'] == 'User is forbidden' @pytest.mark.jira('ACC-7003') def test_get_transaction_types_by_parent_group(basic_headers): """GET /reference-transaction-type-group//reference-transaction-types/.""" ows_abacus_contract_client = conftest.ows_abacus_contract_api_client(basic_headers) res_get = \ ows_abacus_contract_client.get_transaction_types_by_parent_group(1) assert res_get.status_code == 200 assert len(res_get.json()) > 0 for i in res_get.json(): assert 'txn_type_code' in i assert 'txn_type_id' in i assert 'txn_type_name' in i @pytest.mark.jira('PLATFORM-4456') def test_get_transaction_types_by_parent_group_authorization( auth_headers: dict[str, str], unauthorized_headers: dict[str, str], ) -> None: """GET /reference-transaction-type-group//reference-transaction-types.""" client = conftest.ows_abacus_contract_api_client(auth_headers) res = client.get_transaction_types_by_parent_group(1) assert res.status_code == 200 assert len(res.json()) > 0 for i in res.json(): assert 'txn_type_code' in i assert 'txn_type_id' in i assert 'txn_type_name' in i client = conftest.ows_abacus_contract_api_client(unauthorized_headers) res = client.get_transaction_types_by_parent_group(1) assert res.status_code == 403 assert res.json()['message'] == 'User is forbidden'