import pytest from faker import Faker from ows_text_campaigns.artist.models import ArtistPhoneNumber, ArtistSettings from ows_text_campaigns.artist.repositories import ( ArtistPhoneNumberRepository, ArtistSettingsRepository, ) from tests.unit.types import CreateModel class TestArtistPhoneNumberRepository: @pytest.mark.db def test_exists_by_phone_numbers_excluding_global_participant_id( self, repository: ArtistPhoneNumberRepository, create_model: CreateModel, faker: Faker, ) -> None: phone_number = faker.phone_number() global_participant_id = faker.uuid4() create_model(ArtistPhoneNumber, phone_number=phone_number) create_model(ArtistPhoneNumber, global_participant_id=global_participant_id) result = repository.exists_by_phone_numbers_excluding_global_participant_id( phone_numbers=[phone_number], global_participant_id=global_participant_id, ) assert result is True @pytest.mark.db def test_not_exists_by_phone_numbers_excluding_global_participant_id( self, repository: ArtistPhoneNumberRepository, create_model: CreateModel, faker: Faker, ) -> None: phone_number_1 = faker.phone_number() phone_number_2 = faker.phone_number() global_participant_id = faker.uuid4() create_model(ArtistPhoneNumber, phone_number=phone_number_1) create_model(ArtistPhoneNumber, global_participant_id=global_participant_id) result = repository.exists_by_phone_numbers_excluding_global_participant_id( phone_numbers=[phone_number_2], global_participant_id=global_participant_id, ) assert result is False class TestArtistSettingsRepository: @pytest.mark.db def test_get_by_global_participant_id( self, repository: ArtistSettingsRepository, create_model: CreateModel, faker: Faker, ) -> None: global_participant_id = faker.uuid4() artist_phone_number = create_model( ArtistSettings, global_participant_id=global_participant_id, ) result = repository.get_by_global_participant_id(global_participant_id) assert result == artist_phone_number