Пример #1
0
    def test_when_no_next_dow(self, _next, scheduled):
        _next.side_effect = StopIteration

        reminder = {
            '_id': 1,
            'when': datetime.datetime(day=13, month=8, year=2014),
            'repeat': range(7),
        }

        assert reminders.next_occurrence(reminder) is None
        scheduled.discard.assert_called_with(1)
Пример #2
0
    def test_when_no_next_dow(self, _next, scheduled):
        _next.side_effect = StopIteration

        reminder = {
            '_id': 1,
            'when': datetime.datetime(day=13, month=8, year=2014),
            'repeat': range(7),
        }

        assert reminders.next_occurrence(reminder) is None
        scheduled.discard.assert_called_with(1)
Пример #3
0
    def test_next_occurrence(self):
        reminder = {
            '_id': 1,
            # Start on a wednesday
            'when': datetime.datetime(day=13, month=8, year=2014),
        }

        past = (0, 5)  # Expect 5 days in the future
        today = (2, 7)  # Expect 1 week in the future
        future = (5, 3)  # Expect 3 days in the future

        with freeze_time(reminder['when']):
            for repeat, expect_delta in (past, today, future):
                reminder['repeat'] = [repeat]
                next_time, next_delta = reminders.next_occurrence(reminder)
                assert expect_delta == next_delta
                assert next_time == reminder['when'] + datetime.timedelta(days=expect_delta)
Пример #4
0
    def test_next_occurrence(self):
        reminder = {
            '_id': 1,
            # Start on a wednesday
            'when': datetime.datetime(day=13, month=8, year=2014),
        }

        past = (0, 5)  # Expect 5 days in the future
        today = (2, 7)  # Expect 1 week in the future
        future = (5, 3)  # Expect 3 days in the future

        with freeze_time(reminder['when']):
            for repeat, expect_delta in (past, today, future):
                reminder['repeat'] = [repeat]
                next_time, next_delta = reminders.next_occurrence(reminder)
                assert expect_delta == next_delta
                assert next_time == reminder['when'] + datetime.timedelta(
                    days=expect_delta)