Exemple #1
0
    def test_message_with_framing(self, _):
        send_morning_message(username="******")

        self.send_notification.assert_called()
        sent_data = self.send_notification.call_args[1]['data']
        self.assertEqual(sent_data['body'], 'Example morning message')
        self.assertEqual(sent_data['text'], 'Example morning message')
        self.assertEqual(sent_data['anchor'], 'Anchor message')
Exemple #2
0
    def test_creates_morning_message(self):
        send_morning_message(username="******")

        self.send_notification.assert_called()

        morning_message = MorningMessage.objects.get()
        self.assertEqual(morning_message.user, self.user)
        self.assertEqual(morning_message.date, date.today())
Exemple #3
0
    def test_message_with_no_framing(self, _):
        send_morning_message(username="******")

        self.send_notification.assert_called()
        self.assertEqual(self.send_notification.call_args[1]['body'],
                         'Good Morning')
        sent_data = self.send_notification.call_args[1]['data']
        self.assertEqual(sent_data['body'], 'Good Morning')
        assert 'text' not in sent_data
        assert 'anchor' not in sent_data
Exemple #4
0
    def test_disabled_task_state(self):
        self.configuration.enabled = False
        self.configuration.save()

        send_morning_message(username="******")

        self.send_notification.assert_not_called()

        morning_message = MorningMessage.objects.get()
        self.assertEqual(morning_message.user, self.user)
        self.assertEqual(morning_message.date, date.today())
Exemple #5
0
    def test_message_sent_with_collapse_id(self):
        send_morning_message(username='******')

        self.send_notification.assert_called()
        send_kwargs = self.send_notification.call_args[1]
        self.assertEqual(send_kwargs['collapse_subject'], 'morning-message')