Ejemplo n.º 1
0
 def test_simple_push_send(self, requests):
     """Verify that SimplePush registrations are called."""
     u = profile().user
     url = 'http://example.com/simple_push/asdf'
     PushNotificationRegistration.objects.create(creator=u, push_url=url)
     n = notification(owner=u, save=True)
     requests.put.assert_called_once_with(url, 'version={0}'.format(n.id))
Ejemplo n.º 2
0
 def test_simple_push_send(self, requests):
     """Verify that SimplePush registrations are called."""
     u = profile().user
     url = 'http://example.com/simple_push/asdf'
     PushNotificationRegistration.objects.create(creator=u, push_url=url)
     n = notification(owner=u, save=True)
     requests.put.assert_called_once_with(url, 'version={}'.format(n.id))
Ejemplo n.º 3
0
    def test_simple_push_retry(self, requests):
        response = mock.MagicMock()
        response.status_code = 503
        response.json.return_value = {'errno': 202}
        requests.put.return_value = response

        u = profile().user
        url = u'http://example.com/simple_push/asdf'
        PushNotificationRegistration.objects.create(creator=u, push_url=url)
        n = notification(owner=u, save=True)

        # The push notification handler should try, and then retry 3 times before giving up.
        eq_(requests.put.call_args_list, [
            ((url, 'version={}'.format(n.id)), {}),
            ((url, 'version={}'.format(n.id)), {}),
            ((url, 'version={}'.format(n.id)), {}),
            ((url, 'version={}'.format(n.id)), {}),
        ])
Ejemplo n.º 4
0
 def test_simple_push_not_sent(self, requests):
     """Verify that no request is made when there is no SimplePush registration."""
     notification(save=True)
     requests.put.assert_not_called()
Ejemplo n.º 5
0
 def test_is_read_false(self):
     n = notification(read_at=None, save=True)
     eq_(n.is_read, False)
Ejemplo n.º 6
0
 def test_set_is_read_false(self):
     n = notification(read_at=datetime.now(), save=True)
     n.is_read = False
     assert n.read_at is None
Ejemplo n.º 7
0
 def test_set_is_read_true(self):
     n = notification(read_at=None, save=True)
     n.is_read = True
     assert n.read_at is not None
Ejemplo n.º 8
0
 def test_is_read_true(self):
     n = notification(read_at=datetime.now(), save=True)
     eq_(n.is_read, True)
Ejemplo n.º 9
0
 def test_simple_push_not_sent(self, requests):
     """Verify that no request is made when there is no SimplePush registration."""
     notification(save=True)
     requests.put.assert_not_called()
Ejemplo n.º 10
0
 def test_set_is_read_false(self):
     n = notification(read_at=datetime.now(), save=True)
     n.is_read = False
     assert n.read_at is None
Ejemplo n.º 11
0
 def test_set_is_read_true(self):
     n = notification(read_at=None, save=True)
     n.is_read = True
     assert n.read_at is not None
Ejemplo n.º 12
0
 def test_is_read_true(self):
     n = notification(read_at=datetime.now(), save=True)
     eq_(n.is_read, True)
Ejemplo n.º 13
0
 def test_is_read_false(self):
     n = notification(read_at=None, save=True)
     eq_(n.is_read, False)