fix(hands,memory): the daily routine folds into one line and stops crowding out single events
This commit is contained in:
@@ -9,6 +9,7 @@ from beaver_agent.hands.calendars import (
|
||||
calendars,
|
||||
events_in,
|
||||
feeds,
|
||||
is_routine,
|
||||
short,
|
||||
unfold,
|
||||
)
|
||||
@@ -122,6 +123,34 @@ def test_daily_repeat_stops_on_until_and_count():
|
||||
assert starts(yearly) == ["09-06 08:00 часы"]
|
||||
|
||||
|
||||
def test_a_working_week_is_routine_but_one_weekday_a_week_is_an_event():
|
||||
text = ics(
|
||||
"SUMMARY:пара\nDTSTART;TZID=Europe/Warsaw:20260831T100000\n"
|
||||
"RRULE:FREQ=WEEKLY;BYDAY=MO",
|
||||
"SUMMARY:зарядка\nDTSTART;TZID=Europe/Warsaw:20260831T070000\n"
|
||||
"RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR",
|
||||
)
|
||||
found = events_in(text, zone=ZONE, since=NOW.astimezone(ZONE), days=7)
|
||||
assert {e.title for e in found if e.routine} == {"зарядка"}
|
||||
assert {e.title for e in found if not e.routine} == {"пара"}
|
||||
assert len([e for e in found if e.routine]) == 5
|
||||
|
||||
|
||||
def test_routine_is_a_rule_that_fires_once_a_day_or_more_often():
|
||||
assert is_routine({"FREQ": "DAILY"})
|
||||
assert is_routine({"FREQ": "WEEKLY", "BYDAY": "MO,TU,WE,TH,FR,SA"})
|
||||
assert not is_routine({"FREQ": "WEEKLY", "BYDAY": "MO,WE,FR"})
|
||||
assert not is_routine({"FREQ": "WEEKLY"})
|
||||
assert not is_routine({"FREQ": "MONTHLY"})
|
||||
# через день - это уже не быт, такое видно поимённо
|
||||
assert not is_routine({"FREQ": "DAILY", "INTERVAL": "2"})
|
||||
|
||||
|
||||
def test_a_single_event_is_never_routine():
|
||||
text = ics("SUMMARY:Egzamin\nDTSTART:20260903T090000Z")
|
||||
assert not events_in(text, zone=ZONE, since=NOW.astimezone(ZONE), days=7)[0].routine
|
||||
|
||||
|
||||
def test_a_feed_that_fails_becomes_a_line_not_an_exception():
|
||||
class Broken(Calendars):
|
||||
def fetch(self, url: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user