Example #1
0
    def test_compose_message(self):
        notif = APNSNotification(device_token=self.device_token, alert="foobar", badge=1, sound="default")
        import struct

        command, identifier, expiry, token_len, token, payload_len, payload = struct.unpack(
            "!BIIH32sH%ds" % len(notif.get_payload()), str(notif)
        )
        self.assertEquals(command, 1)
        self.assertEquals(identifier, 0)
        self.assertTrue(expiry > 0)
        self.assertEquals(token_len, 32)
        self.assertEquals(payload_len, len(notif.get_payload()))
        self.assertEquals(payload, notif.get_payload())
Example #2
0
    def test_payload_should_not_contain_unused_notification_fields(self):
        notif = APNSNotification(device_token=self.device_token, alert="foobar")
        import json

        payload = json.loads(notif.get_payload())
        self.assertNotIn("badge", payload["aps"])
        self.assertNotIn("sound", payload["aps"])