Coverage for src/tests/modules/club/domain/test_birthdate.py: 100%
16 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module for testing the Birthdate value object."""
3import pendulum
5from kwai_bc_club.domain.value_objects import Birthdate
6from kwai_core.domain.value_objects.date import Date
9def test_age():
10 """Test the age property."""
11 birthdate = Birthdate(Date.create_from_string("1860-10-04"))
12 pendulum.travel_to(pendulum.datetime(year=2024, month=1, day=1))
13 assert birthdate.age == 163
16def test_get_age_in_year():
17 """Test get age in year."""
18 birthdate = Birthdate(Date.create_from_string("1860-10-04"))
19 assert birthdate.get_age_in_year(1938) == 78
22def test_birth_date():
23 """Test birthdate creating from a string."""
24 birthdate = Birthdate(Date.create_from_string("1959-08-11"))
25 assert birthdate.date.year == 1959
26 assert birthdate.date.month == 8
27 assert birthdate.date.day == 11
28 assert str(birthdate) == "1959-08-11"