import pytest from dirty_equals import IsList from fansifter_common.auth.types import JointVentureParticipant from dmp.artists.repositories import ArtistJointVentureRepository from dmp.fandata.models import AccountArtistFullFanDataAccessDbt, FansByArtistAccountDbt from tests.unit.faker import FakerTyped from tests.unit.types import CreateReportingModel class TestArtistJointVentureRepository: @pytest.mark.db def test_find_by_global_participant_id_empty( self, artist_joint_venture_repository: ArtistJointVentureRepository, fake: FakerTyped, ) -> None: global_participant_id = fake.uuid4_string() result = artist_joint_venture_repository.find_by_global_participant_id( global_participant_id ) assert result == [] @pytest.mark.db def test_find_by_global_participant_id_not_found( self, artist_joint_venture_repository: ArtistJointVentureRepository, fake: FakerTyped, create_reporting_model: CreateReportingModel, ) -> 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_repository.find_by_global_participant_id( fake.uuid4_string() ) assert result == [] @pytest.mark.db def test_find_by_global_participant_id( self, artist_joint_venture_repository: ArtistJointVentureRepository, 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_repository.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, ) @pytest.mark.db def test_find_by_global_participant_id_consumer_is_also_provider( self, artist_joint_venture_repository: ArtistJointVentureRepository, fake: FakerTyped, create_reporting_model: CreateReportingModel, ) -> 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( FansByArtistAccountDbt, vendor_id=consumer_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_repository.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=True, 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, ) @pytest.mark.db def test_find_by_global_participant_id_for_specific_provider_vendor_id( self, artist_joint_venture_repository: ArtistJointVentureRepository, create_reporting_model: CreateReportingModel, fake: FakerTyped, ) -> None: global_participant_id = fake.uuid4_string() provider_vendor_id = 1000 additional_fan_data_owner_vendor_id = 2000 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( FansByArtistAccountDbt, vendor_id=additional_fan_data_owner_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=provider_vendor_id, ) result = artist_joint_venture_repository.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, )