def test_notify_link(self): settings = PushoverSettings() settings.access_token = self.real_token settings.user_id = self.read_id self.notifier.update_settings(settings) response = self.notifier.notify('hello', 'yay', 'http://mywebsite.com') self.assertTrue(response)
def test_notify_failed(self): with self.assertRaises(PushoverException) as e: self.notifier.notify('hello', 'yaay') self.assertEqual(e.exception.code, 1) self.assertEqual(e.exception.message, "Access Token or User Id was not specified") settings = PushoverSettings() self.notifier.update_settings(settings) with self.assertRaises(PushoverException) as e: self.notifier.notify('hello', 'yaay') self.assertEqual(e.exception.code, 1) self.assertEqual(e.exception.message, "Access Token or User Id was not specified") settings.access_token = self.fake_token self.notifier.update_settings(settings) with self.assertRaises(PushoverException) as e: self.notifier.notify('hello', 'yaay') self.assertEqual(e.exception.code, 1) self.assertEqual(e.exception.message, "Access Token or User Id was not specified") settings.access_token = None settings.user_id = self.fake_id self.notifier.update_settings(settings) with self.assertRaises(PushoverException) as e: self.notifier.notify('hello', 'yaay') self.assertEqual(e.exception.code, 1) self.assertEqual(e.exception.message, "Access Token or User Id was not specified") settings.access_token = self.fake_token settings.user_id = self.fake_id self.notifier.update_settings(settings) with self.assertRaises(PushoverException) as e: self.notifier.notify('hello', 'yaay') self.assertEqual(e.exception.code, 2) self.assertEqual(e.exception.message, 'Failed to send Pushover notification')