import pytest from dirty_equals import IsList from fansifter_common.auth.types import JointVentureParticipant from dmp.artists.services import ArtistJointVentureService from dmp.fandata.models import AccountArtistFullFanDataAccessDbt, FansByArtistAccountDbt from tests.unit.faker import FakerTyped from tests.unit.types import CreateReportingModel class TestArtistJointVentureService: @pytest.mark.db def test_find_by_global_participant_id_empty( self, artist_joint_venture_service: ArtistJointVentureService, fake: FakerTyped, ) -> None: global_participant_id = fake.uuid4_string() result = artist_joint_venture_service.find_by_global_participant_id( global_participant_id ) assert result == [] @pytest.mark.db def test_find_by_global_participant_id( self, artist_joint_venture_service: ArtistJointVentureService, create_reporting_model: CreateReportingModel, fake: FakerTyped, ) -> None: global_participant_id = fake.uuid4_string() provider_vendor_id = 1000 consumer_vendor_id = 9000 create_reporting_model( FansByArtistAccountDbt, vendor_id=provider_vendor_id, subaccount_id=0, global_participant_id=global_participant_id, ) create_reporting_model( AccountArtistFullFanDataAccessDbt, vendor_id=consumer_vendor_id, subaccount_id=0, global_participant_id=global_participant_id, provider_vendor_id=None, ) result = artist_joint_venture_service.find_by_global_participant_id( global_participant_id ) assert result == IsList( JointVentureParticipant( global_participant_id=global_participant_id, vendor_id=consumer_vendor_id, subaccount_id=0, is_provider=False, is_consumer=True, ), JointVentureParticipant( global_participant_id=global_participant_id, vendor_id=provider_vendor_id, subaccount_id=0, is_provider=True, is_consumer=False, ), check_order=False, )