import pytest from conftest import TEST_YT_ASSET_ID from src.backend.logic.audit.flags import youtube_checks as yt_checks from src.backend.logic.audit.flags.youtube_checks import YtCid class TestYTChecks: _class = yt_checks.YTChecks @pytest.fixture def instance(self): return self._class() @pytest.mark.asyncio async def test_get_asset_match_policies(self, instance): result = await instance.get_asset_match_policies([TEST_YT_ASSET_ID]) match_policies = result[TEST_YT_ASSET_ID] for policy in match_policies: assert isinstance(policy, yt_checks.MatchPolicyRule) assert policy.asset_id == TEST_YT_ASSET_ID @pytest.mark.asyncio async def test_get_asset_ownerships_ours(self, instance): result = await instance.get_asset_ownerships_ours([TEST_YT_ASSET_ID]) ownership_obj = result[TEST_YT_ASSET_ID] assert getattr(ownership_obj, YtCid.OWNER) == yt_checks.YT_OWNER_ID_ORCHARD assert getattr(ownership_obj, YtCid.RATIO) > 0 assert isinstance(getattr(ownership_obj, YtCid.TYPE), str) assert isinstance(getattr(ownership_obj, YtCid.TERRITORIES), list) assert len(ownership_obj) > 0 # Territory count @pytest.mark.asyncio async def test_get_asset_references(self, instance): ref_cache = instance._reference_cache assert not ref_cache, "Expected empty cache" result = await instance.get_asset_references([TEST_YT_ASSET_ID]) result_for_asset = result[TEST_YT_ASSET_ID] assert result_for_asset, "Expected references for asset" assert all( reference.asset_id == TEST_YT_ASSET_ID for reference in result_for_asset ) assert ( ref_cache[TEST_YT_ASSET_ID] == result_for_asset ), "Expected references to have been cached"