Beispiel #1
0
 def _to_object(json_reminder):
     method = json_reminder['method']
     if method == 'email':
         return EmailReminder(int(json_reminder['minutes']))
     elif method == 'popup':
         return PopupReminder(int(json_reminder['minutes']))
     else:
         raise ValueError(
             'Unexpected method "{}" for a reminder.'.format(method))
    def test_to_json(self):
        reminder_json = {'method': 'email', 'minutes': 55}
        reminder = EmailReminder(55)

        self.assertDictEqual(ReminderSerializer.to_json(reminder),
                             reminder_json)

        reminder_json = {'method': 'popup', 'minutes': 13}
        reminder = PopupReminder(13)

        self.assertDictEqual(ReminderSerializer.to_json(reminder),
                             reminder_json)

        serializer = ReminderSerializer(reminder)
        self.assertDictEqual(serializer.get_json(), reminder_json)
Beispiel #3
0
 def test_popup_reminder(self):
     reminder = PopupReminder(51)
     self.assertEqual(reminder.method, 'popup')
     self.assertEqual(reminder.minutes_before_start, 51)