Coverage for src/tests/modules/club/domain/test_contact.py: 100%

17 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2024-01-01 00:00 +0000

1"""Module that defines tests for the ContactEntity.""" 

2 

3import pytest 

4 

5from kwai_bc_club.domain.contact import ContactEntity 

6from kwai_bc_club.domain.country import CountryEntity, CountryIdentifier 

7from kwai_bc_club.domain.value_objects import Address 

8from kwai_core.domain.value_objects.email_address import EmailAddress 

9 

10 

11@pytest.fixture 

12def country() -> CountryEntity: 

13 """A fixture for a country.""" 

14 return CountryEntity( 

15 id=CountryIdentifier(1), iso_2="BE", iso_3="BEL", name="Belgium" 

16 ) 

17 

18 

19def test_add_email(country: CountryEntity): 

20 """Test adding an email address.""" 

21 contact = ContactEntity( 

22 address=Address( 

23 address="", 

24 postal_code="", 

25 city="", 

26 county="", 

27 country=country, 

28 ) 

29 ).add_email(EmailAddress("jigoro.kano@kwai.com")) 

30 assert len(contact.emails) == 1, "There should be 1 email address." 

31 

32 

33def test_remove_email(country: CountryEntity): 

34 """Test adding an email address.""" 

35 contact = ( 

36 ContactEntity( 

37 address=Address( 

38 address="", 

39 postal_code="", 

40 city="", 

41 county="", 

42 country=country, 

43 ) 

44 ) 

45 .add_email(EmailAddress("jigoro.kano@kwai.com")) 

46 .add_email(EmailAddress("jigoro.kano2@kwai.com")) 

47 ) 

48 assert len(contact.emails) == 2, "There should be 2 email addresses." 

49 contact = contact.remove_email(EmailAddress("jigoro.kano@kwai.com")) 

50 assert len(contact.emails) == 1, "There should be 1 email address." 

51 assert contact.emails[0] == EmailAddress("jigoro.kano2@kwai.com")