import httpx import pytest from audience_common.owsclient import AsyncOwsClient from audience_common.owsclient.mock import OwsClientMock from campaigns.connectors.ows_account import OwsAccount @pytest.fixture def ows_account(ows_client: AsyncOwsClient) -> OwsAccount: return OwsAccount(ows_client=ows_client) @pytest.mark.parametrize( "status_code, valid", [ (200, True), (403, False), ], ) async def test_validate_subaccount( status_code: int, valid: bool, ows_account: OwsAccount, ows_client_mock: OwsClientMock, ) -> None: vendor_id = 1000 subaccount_id = 10 ows_client_mock.head( "ows-account", f"/{vendor_id}/subaccount/{subaccount_id}" ).mock(return_value=httpx.Response(status_code=status_code)) result = await ows_account.validate_subaccount( vendor_id=vendor_id, subaccount_id=subaccount_id ) assert result is valid