Implement weekly and custom day-set recurrence (#27)

This commit was merged in pull request #27.
This commit is contained in:
2026-09-14 11:10:39 -04:00
parent 3b638cae6f
commit 23a52707af
3 changed files with 325 additions and 9 deletions
+7 -5
View File
@@ -214,13 +214,14 @@ def test_occurrences_between_year_boundary() -> None:
def test_occurs_on_rejects_unimplemented_shapes_loudly() -> None:
"""Weekly and beyond land with their own engine tasks; a loud
"""Monthly/yearly land with their own engine tasks; a loud
NotImplementedError beats a silent wrong answer."""
rule = ScheduleRule(
rule_type=RuleType.WEEKLY, weekday_set={0}, start_date="2026-09-01"
rule_type=RuleType.MONTHLY_DAY, day_of_month=15,
start_date="2026-09-01",
)
with pytest.raises(NotImplementedError):
occurs_on(rule, _d("2026-09-07"))
occurs_on(rule, _d("2026-09-15"))
def test_interval_7_preserves_weekday_alignment_across_months() -> None:
"""Weekly-by-interval semantics: every firing lands on the SAME
@@ -272,7 +273,7 @@ def test_occurs_on_unimplemented_shape_raises_even_outside_window() -> None:
"""An unimplemented shape must raise whether the date is inside or
outside the window — silent False would hide a missing engine."""
rule = ScheduleRule(
rule_type=RuleType.WEEKLY, weekday_set={0},
rule_type=RuleType.MONTHLY_DAY, day_of_month=15,
start_date="2026-09-01", end_date="2026-09-10",
)
# Before start, inside window, after end: all must raise.
@@ -285,7 +286,8 @@ def test_occurrences_between_unimplemented_shape_raises_even_disjoint(
tmp_path,
) -> None:
rule = ScheduleRule(
rule_type=RuleType.WEEKLY, weekday_set={0}, start_date="2026-09-01"
rule_type=RuleType.MONTHLY_DAY, day_of_month=15,
start_date="2026-09-01"
)
# A range entirely before the rule's start still raises: the shape
# is unimplemented, and silence would hide it.