Exemple #1
0
 def setUp(self):
     super(PushbulletTest, self).setUp()
     self.notifier = PushbulletNotifierPlugin()
     self.helper = PushbulletHelper()
 def setUp(self):
     super(PushbulletTest, self).setUp()
     self.notifier = PushbulletNotifierPlugin()
     self.helper = PushbulletHelper()
Exemple #3
0
class PushbulletTest(DbTestCase):
    def setUp(self):
        super(PushbulletTest, self).setUp()
        self.notifier = PushbulletNotifierPlugin()
        self.helper = PushbulletHelper()

    def test_get_notifier_type(self):
        self.assertEqual(NotifierType.short_text, self.notifier.get_type)

    @use_vcr
    def test_notify_failed(self):
        with self.assertRaises(PushbulletException) as e:
            self.notifier.notify('hello', 'yaay')
        self.assertEqual(e.exception.code, 1)
        self.assertEqual(e.exception.message, "Access Token was not specified")

        settings = PushbulletSettings()
        self.notifier.update_settings(settings)

        with self.assertRaises(PushbulletException) as e:
            self.notifier.notify('hello', 'yaay')
        self.assertEqual(e.exception.code, 1)
        self.assertEqual(e.exception.message, "Access Token was not specified")

        settings.access_token = self.helper.fake_token
        self.notifier.update_settings(settings)
        with self.assertRaises(PushbulletException) as e:
            self.notifier.notify('hello', 'yaay')
        self.assertEqual(e.exception.code, 2)
        self.assertEqual(e.exception.message,
                         'Failed to send Pushbullet notification')

    @use_vcr
    def test_notify(self):
        settings = PushbulletSettings()
        settings.access_token = self.helper.real_token
        self.notifier.update_settings(settings)
        response = self.notifier.notify('hello', 'yay')
        self.assertTrue(response)

    @use_vcr
    def test_notify_link(self):
        settings = PushbulletSettings()
        settings.access_token = self.helper.real_token
        self.notifier.update_settings(settings)
        response = self.notifier.notify('hello', 'yay', 'http://mywebsite.com')
        self.assertTrue(response)
class PushbulletTest(DbTestCase):
    def setUp(self):
        super(PushbulletTest, self).setUp()
        self.notifier = PushbulletNotifierPlugin()
        self.helper = PushbulletHelper()

    @use_vcr
    def test_notify_failed(self):
        with self.assertRaises(PushbulletException) as e:
            self.notifier.notify('hello', 'yaay')
        self.assertEqual(e.exception.code, 1)
        self.assertEqual(e.exception.message, "Access Token was not specified")

        settings = PushbulletSettings()
        self.notifier.update_settings(settings)

        with self.assertRaises(PushbulletException) as e:
            self.notifier.notify('hello', 'yaay')
        self.assertEqual(e.exception.code, 1)
        self.assertEqual(e.exception.message, "Access Token was not specified")

        settings.access_token = self.helper.fake_token
        self.notifier.update_settings(settings)
        with self.assertRaises(PushbulletException) as e:
            self.notifier.notify('hello', 'yaay')
        self.assertEqual(e.exception.code, 2)
        self.assertEqual(e.exception.message, 'Failed to send Pushbullet notification')

    @use_vcr
    def test_notify(self):
        settings = PushbulletSettings()
        settings.access_token = self.helper.real_token
        self.notifier.update_settings(settings)
        response = self.notifier.notify('hello', 'yay')
        self.assertTrue(response)

    @use_vcr
    def test_notify_link(self):
        settings = PushbulletSettings()
        settings.access_token = self.helper.real_token
        self.notifier.update_settings(settings)
        response = self.notifier.notify('hello', 'yay', 'http://mywebsite.com')
        self.assertTrue(response)