"""Tests for the label-profile-access endpoint. GET /users/identity//label-profile-access/ """ import pytest import requests from tests.integration import config, constants _IDENTITY_ID = constants.LINKED_LABEL_PROFILE_IDENTITY_ID _PROFILE_ACTIVE_VENDOR = '10208211' _PROFILE_SOFT_DELETED_VENDOR = '10208212' _PROFILE_ACTIVE_SUBACCOUNT = '10208213' _PROFILE_SOFT_DELETED_SUBACCOUNT = '10208214' @pytest.mark.parametrize( ('identity_id', 'label_profile_id', 'expected_has_access'), [ pytest.param( _IDENTITY_ID, _PROFILE_ACTIVE_VENDOR, True, id='active vendor profile is included', ), pytest.param( _IDENTITY_ID, _PROFILE_SOFT_DELETED_VENDOR, False, id='soft-deleted vendor profile is excluded', ), pytest.param( _IDENTITY_ID, _PROFILE_ACTIVE_SUBACCOUNT, True, id='active subaccount profile is included', ), pytest.param( _IDENTITY_ID, _PROFILE_SOFT_DELETED_SUBACCOUNT, False, id='soft-deleted subaccount profile is excluded', ), pytest.param( constants.GRASS_HEADERS_IDENTITY_ID, '0', False, id='identity does not own this label profile', ), pytest.param( constants.INTEGRATION_TEST_USER_IDENTITY_ID, _PROFILE_ACTIVE_VENDOR, False, id='different identity does not own this label profile', ), ], ) def test_check_label_profile_access( grass_headers, identity_id, label_profile_id, expected_has_access ) -> None: """Endpoint returns has_access=True only when the identity holds the LabelProfile.""" res = requests.get( f'{config.QA_BASE_URL}/users/identity/{identity_id}' f'/label-profile-access/{label_profile_id}', headers=grass_headers, ) assert res.status_code == 200 assert res.json() == {'has_access': expected_has_access}