mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Item validity: Compute month ranges one day shorter
This commit is contained in:
@@ -42,12 +42,13 @@ def dt(*args, is_dst=None, **kwargs):
|
||||
(0, 0, 1, 0, dt(2023, 2, 9, 10, 30, 0), dt(2023, 2, 9, 23, 59, 59)), # "day pass"
|
||||
(0, 0, 3, 0, dt(2023, 2, 9, 10, 30, 0), dt(2023, 2, 11, 23, 59, 59)), # "3-day pass"
|
||||
(30, 6, 3, 0, dt(2023, 2, 9, 10, 30, 0), dt(2023, 2, 12, 6, 29, 59)), # "3-day pass with day end at 6:30"
|
||||
(0, 0, 0, 1, dt(2023, 2, 9, 10, 30, 0), dt(2023, 3, 9, 23, 59, 59)), # "month pass"
|
||||
(0, 0, 3, 1, dt(2023, 2, 9, 10, 30, 0), dt(2023, 3, 12, 23, 59, 59)), # "month pass + 3 days"
|
||||
(30, 6, 0, 1, dt(2023, 2, 9, 10, 30, 0), dt(2023, 3, 10, 6, 29, 59)), # "month pass with day end at 6:30"
|
||||
(30, 6, 1, 1, dt(2023, 2, 9, 10, 30, 0), dt(2023, 3, 11, 6, 29, 59)), # "month pass + 1 day with day end at 6:30"
|
||||
(0, 0, 0, 12, dt(2023, 2, 9, 10, 30, 0), dt(2024, 2, 9, 23, 59, 59)), # "year pass"
|
||||
(30, 6, 0, 12, dt(2023, 2, 9, 10, 30, 0), dt(2024, 2, 10, 6, 29, 59)), # "year pass with day end at 6:30"
|
||||
(0, 0, 0, 1, dt(2023, 2, 9, 10, 30, 0), dt(2023, 3, 8, 23, 59, 59)), # "month pass"
|
||||
(0, 0, 3, 1, dt(2023, 2, 9, 10, 30, 0), dt(2023, 3, 11, 23, 59, 59)), # "month pass + 3 days"
|
||||
(30, 6, 0, 1, dt(2023, 2, 9, 10, 30, 0), dt(2023, 3, 9, 6, 29, 59)), # "month pass with day end at 6:30"
|
||||
(30, 6, 1, 1, dt(2023, 2, 9, 10, 30, 0), dt(2023, 3, 10, 6, 29, 59)), # "month pass + 1 day with day end at 6:30"
|
||||
(0, 0, 0, 12, dt(2023, 2, 9, 10, 30, 0), dt(2024, 2, 8, 23, 59, 59)), # "year pass"
|
||||
(0, 0, 0, 12, dt(2023, 1, 1, 10, 30, 0), dt(2023, 12, 31, 23, 59, 59)), # "year pass"
|
||||
(30, 6, 0, 12, dt(2023, 2, 9, 10, 30, 0), dt(2024, 2, 9, 6, 29, 59)), # "year pass with day end at 6:30"
|
||||
|
||||
# Calendrical edge cases
|
||||
|
||||
@@ -55,9 +56,9 @@ def dt(*args, is_dst=None, **kwargs):
|
||||
(0, 0, 2, 0, dt(2023, 3, 25, 10, 30, 0), dt(2023, 3, 26, 23, 59, 59)),
|
||||
|
||||
# Month + day across a DST change
|
||||
(0, 0, 1, 1, dt(2023, 2, 25, 10, 30, 0), dt(2023, 3, 26, 23, 59, 59)),
|
||||
(0, 0, 1, 1, dt(2023, 2, 26, 10, 30, 0), dt(2023, 3, 26, 23, 59, 59)),
|
||||
|
||||
# Day + hour with possibly non-existant end time during DST change
|
||||
# Day + hour with possibly non-existent end time during DST change
|
||||
(30, 2, 1, 0, dt(2023, 3, 25, 10, 30, 0), dt(2023, 3, 26, 3, 29, 59)),
|
||||
|
||||
# Day + hour with ambiguous end time during DST change
|
||||
@@ -65,11 +66,17 @@ def dt(*args, is_dst=None, **kwargs):
|
||||
|
||||
# Month with short month following
|
||||
(0, 0, 0, 1, dt(2023, 1, 31, 10, 30, 0), dt(2023, 2, 28, 23, 59, 59)),
|
||||
(0, 0, 0, 1, dt(2023, 1, 30, 10, 30, 0), dt(2023, 2, 28, 23, 59, 59)),
|
||||
(0, 0, 0, 1, dt(2023, 1, 29, 10, 30, 0), dt(2023, 2, 28, 23, 59, 59)),
|
||||
(0, 0, 0, 1, dt(2023, 1, 28, 10, 30, 0), dt(2023, 2, 27, 23, 59, 59)),
|
||||
(0, 0, 0, 1, dt(2023, 2, 1, 10, 30, 0), dt(2023, 2, 28, 23, 59, 59)),
|
||||
|
||||
# Interaction on months and leap days
|
||||
(0, 0, 0, 1, dt(2024, 1, 31, 10, 30, 0), dt(2024, 2, 29, 23, 59, 59)),
|
||||
(0, 0, 0, 12, dt(2023, 3, 1, 10, 30, 0), dt(2024, 2, 29, 23, 59, 59)),
|
||||
(0, 0, 0, 12, dt(2024, 3, 1, 10, 30, 0), dt(2025, 2, 28, 23, 59, 59)),
|
||||
(0, 0, 0, 12, dt(2024, 2, 29, 10, 30, 0), dt(2025, 2, 28, 23, 59, 59)),
|
||||
(0, 0, 0, 12, dt(2024, 1, 31, 10, 30, 0), dt(2025, 1, 31, 23, 59, 59)),
|
||||
(0, 0, 0, 12, dt(2024, 1, 31, 10, 30, 0), dt(2025, 1, 30, 23, 59, 59)),
|
||||
])
|
||||
def test_dynamic_validity(minutes, hours, days, months, start, expected_end):
|
||||
i = Item(
|
||||
|
||||
Reference in New Issue
Block a user