Ejemplo n.º 1
0
 def test_notify_link(self):
     settings = PushAllSettings()
     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)
Ejemplo n.º 2
0
 def test_notify_link(self):
     settings = PushAllSettings()
     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)
Ejemplo n.º 3
0
 def test_notify(self):
     settings = PushAllSettings()
     settings.access_token = self.real_token
     settings.user_id = self.read_id
     self.notifier.update_settings(settings)
     response = self.notifier.notify("hello", "yay")
     self.assertTrue(response)
Ejemplo n.º 4
0
    def test_notify_failed(self):
        with self.assertRaises(PushAllException) 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 = PushAllSettings()
        self.notifier.update_settings(settings)

        with self.assertRaises(PushAllException) 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(PushAllException) 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(PushAllException) 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(PushAllException) as e:
            self.notifier.notify('hello', 'yaay')
        self.assertEqual(e.exception.code, 2)
        self.assertEqual(e.exception.message,
                         'Failed to send PushAll notification')
Ejemplo n.º 5
0
    def test_notify_failed(self):
        with self.assertRaises(PushAllException) 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 = PushAllSettings()
        self.notifier.update_settings(settings)

        with self.assertRaises(PushAllException) 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(PushAllException) 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(PushAllException) 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(PushAllException) as e:
            self.notifier.notify('hello', 'yaay')
        self.assertEqual(e.exception.code, 2)
        self.assertEqual(e.exception.message, 'Failed to send PushAll notification')