~homeworkprod/byceps

ref: 9f63b62a2b4647a97ebd3b6356d937ffa1d88876 byceps/tests/services/user/test_models_age.py -rw-r--r-- 587 bytes
9f63b62a — Jochen Kupperschmidt Note that Python 3.6 is a supported Python version 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from datetime import date

from freezegun import freeze_time
from nose2.tools import params

from testfixtures.user import create_user_with_detail


@params(
    ('2014-03-17', 19),
    ('2014-03-18', 20),
    ('2014-03-19', 20),
    ('2015-03-17', 20),
    ('2015-03-18', 21),
    ('2015-03-19', 21),
)
def test_age(today_text, expected):
    user = create_user_with_detail(date_of_birth=date(1994, 3, 18))

    with freeze_time(today_text):
        assert user.detail.age == expected