예제 #1
0
 def test_simple_push_send(self, requests):
     """Verify that SimplePush registrations are called."""
     u = UserFactory()
     url = 'http://example.com/simple_push/asdf'
     PushNotificationRegistration.objects.create(creator=u, push_url=url)
     n = NotificationFactory(owner=u)
     requests.put.assert_called_once_with(url, 'version={}'.format(n.id))
예제 #2
0
    def test_simple_push_send(self, requests):
        """Verify that SimplePush registrations are called."""
        response = mock.Mock()
        response.status_code = 200
        requests.put.return_value = response

        u = UserFactory()
        url = "http://example.com/simple_push/asdf"
        PushNotificationRegistration.objects.create(creator=u, push_url=url)
        n = NotificationFactory(owner=u)
        requests.put.assert_called_once_with(url, "version={}".format(n.id))
예제 #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 = UserFactory()
        url = 'http://example.com/simple_push/asdf'
        PushNotificationRegistration.objects.create(creator=u, push_url=url)
        n = NotificationFactory(owner=u)

        # 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)), {}),
        ])
예제 #4
0
 def test_simple_push_not_sent(self, requests):
     """Verify that no request is made when there is no SimplePush registration."""
     NotificationFactory()
     requests.put.assert_not_called()
예제 #5
0
 def test_set_is_read_false(self):
     n = NotificationFactory(read_at=datetime.now())
     n.is_read = False
     assert n.read_at is None
예제 #6
0
 def test_set_is_read_true(self):
     n = NotificationFactory(read_at=None)
     n.is_read = True
     assert n.read_at is not None
예제 #7
0
 def test_is_read_false(self):
     n = NotificationFactory(read_at=None)
     eq_(n.is_read, False)
예제 #8
0
 def test_set_is_read_false(self):
     n = NotificationFactory(read_at=datetime.now())
     n.is_read = False
     assert n.read_at is None
예제 #9
0
 def test_set_is_read_true(self):
     n = NotificationFactory(read_at=None)
     n.is_read = True
     assert n.read_at is not None
예제 #10
0
 def test_is_read_true(self):
     n = NotificationFactory(read_at=datetime.now())
     eq_(n.is_read, True)