Total Complexity | 8 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | 1 | import pytest |
|
2 | |||
3 | 1 | from decimaldate import DecimalDate |
|
4 | |||
5 | |||
6 | 1 | def test_count_step_0_raises_value_error() -> None: |
|
7 | 1 | it = iter(DecimalDate.count(step=0)) |
|
8 | 1 | with pytest.raises(expected_exception=ValueError): |
|
9 | 1 | _ = next(it) |
|
10 | |||
11 | |||
12 | 1 | def test_count_step_none_raises_type_error() -> None: |
|
13 | 1 | it = iter(DecimalDate.count(step=None)) # type: ignore[arg-type] # NOSONAR |
|
14 | 1 | with pytest.raises(expected_exception=TypeError): |
|
15 | 1 | _ = next(it) |
|
16 | |||
17 | |||
18 | 1 | def test_count_step_1(today_as_decimaldate_int) -> None: |
|
19 | # GIVEN |
||
20 | 1 | step = 1 |
|
21 | # WHEN |
||
22 | 1 | it = iter(DecimalDate.count(step=step)) |
|
23 | # THEN |
||
24 | 1 | assert next(it).as_int() == today_as_decimaldate_int |
|
25 | 1 | assert ( |
|
26 | next(it).as_int() == DecimalDate(today_as_decimaldate_int).next(step).as_int() |
||
27 | ) |
||
28 | |||
29 | |||
30 | 1 | def test_count_step_neg1(today_as_decimaldate_int) -> None: |
|
31 | # GIVEN |
||
32 | 1 | step = -1 |
|
33 | # WHEN |
||
34 | 1 | it = iter(DecimalDate.count(step=step)) |
|
35 | # THEN |
||
36 | 1 | assert next(it).as_int() == today_as_decimaldate_int |
|
37 | 1 | assert ( |
|
38 | next(it).as_int() == DecimalDate(today_as_decimaldate_int).next(step).as_int() |
||
39 | ) |
||
40 | |||
41 | |||
42 | 1 | def test_count_step_17(today_as_decimaldate_int) -> None: |
|
43 | # GIVEN |
||
44 | 1 | step = 17 |
|
45 | # WHEN |
||
46 | 1 | it = iter(DecimalDate.count(step=step)) |
|
47 | # THEN |
||
48 | 1 | assert next(it).as_int() == today_as_decimaldate_int |
|
49 | 1 | assert ( |
|
50 | next(it).as_int() == DecimalDate(today_as_decimaldate_int).next(step).as_int() |
||
51 | ) |
||
52 | |||
53 | |||
54 | 1 | def test_count_step_neg17(today_as_decimaldate_int) -> None: |
|
55 | # GIVEN |
||
56 | 1 | step = -17 |
|
57 | # WHEN |
||
58 | 1 | it = iter(DecimalDate.count(step=step)) |
|
59 | # THEN |
||
60 | 1 | assert next(it).as_int() == today_as_decimaldate_int |
|
61 | 1 | assert ( |
|
62 | next(it).as_int() == DecimalDate(today_as_decimaldate_int).next(step).as_int() |
||
63 | ) |
||
64 |