import decimal import pytest from dmp.artists.repositories import ArtistMaxSpendRepository from dmp.fandata.models import ArtistMaxSpendDbt from tests.unit.faker import FakerTyped from tests.unit.types import CreateReportingModel class TestArtistMaxSpendRepository: @pytest.mark.db def test_get_max_spend_empty( self, artist_max_spend_repository: ArtistMaxSpendRepository, fake: FakerTyped, ) -> None: max_spend = artist_max_spend_repository.get_max_spend( vendor_id=fake.integer(), subaccount_id=fake.integer(), global_participant_ids=[fake.uuid4_string()], ) assert max_spend == 0 @pytest.mark.db def test_get_max_spend( self, artist_max_spend_repository: ArtistMaxSpendRepository, create_reporting_model: CreateReportingModel, fake: FakerTyped, ) -> None: vendor_id = fake.integer() subaccount_id = fake.integer() global_participant_id_1 = fake.uuid4_string() global_participant_id_2 = fake.uuid4_string() create_reporting_model( ArtistMaxSpendDbt, global_participant_id=global_participant_id_1, vendor_id=vendor_id, subaccount_id=subaccount_id, max_spend=100.20, ) create_reporting_model( ArtistMaxSpendDbt, global_participant_id=global_participant_id_2, vendor_id=vendor_id, subaccount_id=subaccount_id, max_spend=10.50, ) max_spend = artist_max_spend_repository.get_max_spend( vendor_id=vendor_id, subaccount_id=subaccount_id, global_participant_ids=[ global_participant_id_1, global_participant_id_2, ], is_global=False, ) assert max_spend == decimal.Decimal("100.2")