Exemplo n.º 1
0
    def test_unclaim_empty(self):
        message = Message([_token1, _token2], {})
        ok = self.queue.unclaim(next(message.notifications()))

        self.assertFalse(ok)
        self.assertEqual(len(self.queue._queue), 0)
        self.assertEqual(self.queue._next, 0)
Exemplo n.º 2
0
    def test_frame_2(self):
        msg = Message([_token1], {'aps': {'badge': 1}}, expiration=datetime(2015, 1, 1), priority=5)
        frames = [notif.frame() for notif in msg.notifications()]

        self.assertEqual(
            frames,
            [b'\x02\x00\x00\x00D\x01\x00 \x1b\xa9z\xd11\x13\x07\xc1\x89in#i\xc8\x9f\xa8=e&\x11\xa6\xe3\xc77\x08\x81(\x9eEf\x8f\xd3\x02\x00\x13{"aps":{"badge":1}}\x04\x00\x04T\xa4\x8e\x00\x05\x00\x01\x05']
        )
Exemplo n.º 3
0
    def test_frame_1(self):
        msg = Message([_token1], {'aps': {'badge': 1}})
        frames = [notif.frame() for notif in msg.notifications()]

        self.assertEqual(
            frames,
            [b'\x02\x00\x00\x009\x01\x00 \x1b\xa9z\xd11\x13\x07\xc1\x89in#i\xc8\x9f\xa8=e&\x11\xa6\xe3\xc77\x08\x81(\x9eEf\x8f\xd3\x02\x00\x13{"aps":{"badge":1}}']
        )
Exemplo n.º 4
0
    def test_frame_multiple(self):
        msg = Message([_token1, _token2], {'aps': {'badge': 1}}, expiration=datetime(2015, 1, 1), priority=5)
        frames = [notif.frame() for notif in msg.notifications()]

        self.assertEqual(
            frames,
            [
                b'\x02\x00\x00\x00D\x01\x00 \x1b\xa9z\xd11\x13\x07\xc1\x89in#i\xc8\x9f\xa8=e&\x11\xa6\xe3\xc77\x08\x81(\x9eEf\x8f\xd3\x02\x00\x13{"aps":{"badge":1}}\x04\x00\x04T\xa4\x8e\x00\x05\x00\x01\x05',
                b'\x02\x00\x00\x00D\x01\x00 L#\xf0B\x05\x0fH\xda5\x0c\xb1\x07\x9da\x18\x9c\xf7\xa4|\xb8\xdf\x08t)\xc0\xb2\xdae"l\xbe\xcc\x02\x00\x13{"aps":{"badge":1}}\x04\x00\x04T\xa4\x8e\x00\x05\x00\x01\x05',
            ]
        )