Пример #1
0
    def test_do_reminder_simple(self, db):
        db.reminders.find_one.return_value = self.rec
        reminders._do_reminder(1, self.client)

        assert 1 not in reminders._scheduled
        db.reminders.remove.assert_called_with(1)
        self.client.msg.assert_called_with('#bots', 'some message')
Пример #2
0
    def test_do_reminder_simple(self, db):
        db.reminders.find_one.return_value = self.rec
        reminders._do_reminder(1, self.client)

        assert 1 not in reminders._scheduled
        db.reminders.remove.assert_called_with(1)
        self.client.msg.assert_called_with('#bots', 'some message')
Пример #3
0
 def test_handles_unicode(self, db):
     client = Mock()
     snowman = u'☃'
     reminder = {
         'channel': snowman,
         'message': snowman,
     }
     db.reminders.find_one.return_value = reminder
     reminders._do_reminder(1, client)
     client.msg.assert_called_with(snowman, snowman)
Пример #4
0
 def test_handles_unicode(self, db):
     client = Mock()
     snowman = u'☃'
     reminder = {
         'channel': snowman,
         'message': snowman,
     }
     db.reminders.find_one.return_value = reminder
     reminders._do_reminder(1, client)
     client.msg.assert_called_with(snowman, snowman)
Пример #5
0
    def test_do_reminder_reschedules_next_week(self, reactor, db):
        self.rec['when'] = datetime.datetime(day=13, month=12, year=2013)
        self.rec['repeat'] = [0, 2, 4]  # M, W, F
        db.reminders.find_one.return_value = self.rec

        with freeze_time(self.rec['when']):
            reminders._do_reminder(1, self.client)

        rec_upd = self.rec.copy()
        rec_upd['when'] = datetime.datetime(day=16, month=12, year=2013)

        db.reminders.save.assert_called_with(rec_upd)
        reactor.callLater.assert_called_with(72 * 3600, reminders._do_reminder, 1, self.client)
Пример #6
0
    def test_do_reminder_reschedules_next_week(self, reactor, db):
        self.rec['when'] = datetime.datetime(day=13, month=12, year=2013)
        self.rec['repeat'] = [0, 2, 4]  # M, W, F
        db.reminders.find_one.return_value = self.rec

        with freeze_time(self.rec['when']):
            reminders._do_reminder(1, self.client)

        rec_upd = self.rec.copy()
        rec_upd['when'] = datetime.datetime(day=16, month=12, year=2013)

        db.reminders.save.assert_called_with(rec_upd)
        reactor.callLater.assert_called_with(72 * 3600, reminders._do_reminder,
                                             1, self.client)
Пример #7
0
 def test_scheduled_discarded_with_no_record(self, db, scheduled):
     db.reminders.find_one.return_value = None
     reminders._do_reminder(1, Mock())
     scheduled.discard.assert_called_with(1)
Пример #8
0
 def test_scheduled_discarded_with_no_record(self, db, scheduled):
     db.reminders.find_one.return_value = None
     reminders._do_reminder(1, Mock())
     scheduled.discard.assert_called_with(1)