import pytest from dmp.artists.handlers import ( GetArtistAccountsAllHandler, GetArtistAccountsAllRequest, ) from dmp.fandata.models import FansByArtistAccountDbt from tests.unit.faker import FakerTyped from tests.unit.types import CreateReportingModel class TestGetArtistAccountsAllHandler: @pytest.mark.db def test_get_artist_accounts_empty( self, handler: GetArtistAccountsAllHandler, fake: FakerTyped ) -> None: artist_accounts = handler.handle( GetArtistAccountsAllRequest( global_participant_id=fake.uuid4_string(), ) ) assert artist_accounts == [] @pytest.mark.db def test_get_artist_accounts_all_global_participant_id( self, handler: GetArtistAccountsAllHandler, fake: FakerTyped, create_reporting_model: CreateReportingModel, ) -> None: global_participant_id = fake.uuid4_string() vendor_id_1 = fake.integer() vendor_id_2 = vendor_id_1 + 1 account_1 = create_reporting_model( FansByArtistAccountDbt, global_participant_id=global_participant_id, vendor_id=vendor_id_1, ) account_2 = create_reporting_model( FansByArtistAccountDbt, global_participant_id=global_participant_id, vendor_id=vendor_id_2, ) artist_accounts = handler.handle( GetArtistAccountsAllRequest( global_participant_id=global_participant_id, ) ) assert len(artist_accounts) == 2 assert artist_accounts[0].vendor_id == account_1.vendor_id assert artist_accounts[0].subaccount_id == account_1.subaccount_id assert artist_accounts[1].vendor_id == account_2.vendor_id assert artist_accounts[1].subaccount_id == account_2.subaccount_id