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