~homeworkprod/byceps

ref: 1181a35dd06d48c779208a6d2a4b3672dd38d812 byceps/tests/services/user/test_models_age.py -rw-r--r-- 613 bytes
1181a35d — Jochen Kupperschmidt Ported tests from nose2 to pytest 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
import pytest

from testfixtures.user import create_user_with_detail


@pytest.mark.parametrize('today_text, expected', [
    ('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