Example #1
0
    def test_send_message_exception(self, request_mock):
        request_mock.side_effect = requests.RequestException
        api = PushoverApi('SECRET_TOKEN')

        with pytest.raises(PushoverException) as exc:
            api.send_message({})

        assert isinstance(exc.value.args[0], requests.RequestException) is True
Example #2
0
def notify(level, instance, signal=None, **kwargs):
    if 'observer' in kwargs:
        title = '{0}: {1}'.format(level.upper(), kwargs['observer'].name)
    else:
        title = kwargs.pop('title', instance)

    api = PushoverApi(settings.PUSHOVER_TOKEN)
    api.send_notification(
        settings.PUSHOVER_RECIPIENT, title, level, alert=instance, **kwargs)
Example #3
0
    def emit(self, record):
        try:
            from django.conf import settings
            from terrarium.watchdog.pushover import PushoverApi

            kwargs = {
                'record': record,
            }

            api = PushoverApi(settings.PUSHOVER_TOKEN)
            api.send_notification(
                settings.PUSHOVER_RECIPIENT_SERVER_ERROR, 'Server Error', 'server', **kwargs)
        except:
            pass
Example #4
0
    def test_send_message(self, request_mock):
        request_mock.return_value = requests.Response()
        api = PushoverApi('SECRET_TOKEN')

        assert isinstance(api.send_message({}), requests.Response) is True