~homeworkprod/byceps

ref: 9f63b62a2b4647a97ebd3b6356d937ffa1d88876 byceps/tests/util/datetime/test_monthday.py -rw-r--r-- 1.0 KiB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from datetime import date

from nose2.tools import params

from byceps.util.datetime.monthday import MonthDay


@params(
    (date(1994,  3, 18),  3, 18),
    (date(2012,  9, 27),  9, 27),
    (date(2015,  1,  1),  1,  1),
    (date(2022, 12, 31), 12, 31),
)
def test_of(date, expected_month, expected_day):
    month_day = MonthDay.of(date)

    assert month_day.month == expected_month
    assert month_day.day == expected_day


@params(
    ( 3, 17, date(2005,  2, 17), False),
    ( 3, 17, date(2005,  3, 16), False),
    ( 3, 17, date(2005,  3, 17), True ),
    ( 3, 17, date(2014,  3, 17), True ),
    ( 3, 17, date(2017,  3, 17), True ),
    ( 3, 17, date(2005,  3, 18), False),
    ( 3, 17, date(2005,  4, 17), False),
    (12, 31, date(2010, 12, 30), False),
    (12, 31, date(2010, 12, 31), True ),
)
def test_matches(month, day, date, expected):
    month_day = MonthDay(month=month, day=day)

    actual = month_day.matches(date)

    assert actual == expected