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))
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))
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)), {}), ])
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()
def test_is_read_false(self): n = notification(read_at=None, save=True) eq_(n.is_read, False)
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
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
def test_is_read_true(self): n = notification(read_at=datetime.now(), save=True) eq_(n.is_read, True)