import pytest from dmp.rosters.models import ArtistRosterLocalRep, ArtistRosterMainRep from dmp.rosters.repositories import ArtistRosterMainRepRepository from tests.unit.types import CreateReportingModel class TestArtistRosterMainRepRepository: @pytest.mark.db def test_exists_by_artist_and_any_account( self, repository: ArtistRosterMainRepRepository ) -> None: exists = repository.exists_by_artist_and_any_account( global_participant_id="global_participant_id", vendor_ids=[1], subaccount_ids=[1], ) assert not exists @pytest.mark.db def test_exists_by_artist_and_any_account_empty_vendors( self, repository: ArtistRosterMainRepRepository ) -> None: exists = repository.exists_by_artist_and_any_account( global_participant_id="global_participant_id", vendor_ids=[], subaccount_ids=[1], ) assert not exists @pytest.mark.db def test_exists_by_artist_and_any_account_in_main_rep( self, repository: ArtistRosterMainRepRepository, create_reporting_model: CreateReportingModel, ) -> None: main_rep = create_reporting_model(ArtistRosterMainRep, status="ACTIVE") exists = repository.exists_by_artist_and_any_account( global_participant_id=main_rep.global_participant_id, vendor_ids=[main_rep.vendor_id], subaccount_ids=[main_rep.subaccount_id], ) assert exists @pytest.mark.db def test_exists_by_artist_and_any_account_in_local_rep( self, repository: ArtistRosterMainRepRepository, create_reporting_model: CreateReportingModel, ) -> None: local_rep = create_reporting_model(ArtistRosterLocalRep) exists = repository.exists_by_artist_and_any_account( global_participant_id=local_rep.global_participant_id, vendor_ids=[local_rep.vendor_id], subaccount_ids=[local_rep.subaccount_id], ) assert exists @pytest.mark.db def test_exists_by_account_and_global_participant_ids( self, repository: ArtistRosterMainRepRepository, create_reporting_model: CreateReportingModel, ) -> None: main_rep = create_reporting_model(ArtistRosterMainRep) exists = repository.exists_by_account_and_global_participant_ids( vendor_id=main_rep.vendor_id, subaccount_id=main_rep.subaccount_id, global_participant_ids=[main_rep.global_participant_id], ) assert exists @pytest.mark.db def test_exists_by_account_and_empty_global_participant_ids( self, repository: ArtistRosterMainRepRepository, create_reporting_model: CreateReportingModel, ) -> None: main_rep = create_reporting_model(ArtistRosterMainRep) exists = repository.exists_by_account_and_global_participant_ids( vendor_id=main_rep.vendor_id, subaccount_id=main_rep.subaccount_id, global_participant_ids=[], ) assert not exists @pytest.mark.db def test_find_by_artist_and_any_account_in_main_rep( self, repository: ArtistRosterMainRepRepository, create_reporting_model: CreateReportingModel, ) -> None: main_rep = create_reporting_model(ArtistRosterMainRep) main_reps = repository.find_by_artist_and_any_account( global_participant_id=main_rep.global_participant_id, vendor_ids=[main_rep.vendor_id], subaccount_ids=[main_rep.subaccount_id], ) assert main_reps == [main_rep] @pytest.mark.db def test_find_by_artist_and_any_account_in_main_rep_not_allowed( self, repository: ArtistRosterMainRepRepository, create_reporting_model: CreateReportingModel, ) -> None: main_rep = create_reporting_model(ArtistRosterMainRep) main_reps = repository.find_by_artist_and_any_account( global_participant_id=main_rep.global_participant_id, vendor_ids=[], subaccount_ids=[], ) assert main_reps == []