Skip to content

Commit

Permalink
Test incomplete alarms
Browse files Browse the repository at this point in the history
  • Loading branch information
niccokunzmann committed Nov 2, 2024
1 parent fab00aa commit 72b2489
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/icalendar/alarms.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ def _repeat(self, first: datetime, alarm: Alarm) -> Generator[datetime]:
"""The times when the alarm is triggered relative to start."""
yield first # we trigger at the start
repeat = alarm.REPEAT
if repeat:
duration = alarm.DURATION
duration = alarm.DURATION
if repeat and duration:
for i in range(1, repeat + 1):
yield self._add(first, duration * i)

Expand Down
14 changes: 12 additions & 2 deletions src/icalendar/tests/test_issue_716_alarm_time_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,19 @@ def test_absolute_alarm_time_with_vDatetime(alarm):
assert times[0].trigger == EXAMPLE_TRIGGER


def test_alarm_has_only_one_of_repeat_or_duration():
alarm_incomplete_1 = Alarm()
alarm_incomplete_1.TRIGGER = timedelta(hours=2)
alarm_incomplete_1.DURATION = timedelta(hours=1)
alarm_incomplete_2 = Alarm()
alarm_incomplete_2.TRIGGER = timedelta(hours=2)
alarm_incomplete_2.REPEAT = 100

@pytest.mark.parametrize("alarm", [alarm_incomplete_1, alarm_incomplete_2])
def test_alarm_has_only_one_of_repeat_or_duration(alarm):
"""This is an edge case and we should ignore the repetition."""
pytest.skip("TODO")
a = Alarms(alarm)
a.set_start(datetime(2027, 12, 2))
assert len(a.times) == 1


@pytest.fixture(params=[(0, timedelta(minutes=-30)), (1, timedelta(minutes=-25))])
Expand Down

0 comments on commit 72b2489

Please sign in to comment.