예제 #1
0
    def test_send_message_no_expiration_date(self):
        msg = Message()
        gcm_srv = BBPushService({'api_id': API_ID, 'password': PASSWORD})
        device_list = [Device(BBPushService.type, TOKEN)]

        push_response = gcm_srv.send(msg, device_list)

        self.assertIsInstance(push_response, PushResponse)
        self.assertTrue(
            push_response.code in (1000, 1001, 2001, 2002, 2004, 4001, 21000),
            '\nStatus Code %i:\n%s\n' %
            (push_response.code, push_response.description))
예제 #2
0
    def test_push_manager_send(self):
        pm = PushManager(
            [GCMPushService(GCM_OPS),
             BBPushService(BLACKBERRY_OPS)])

        msg = Message()
        device_list = [
            Device(BBPushService.type, TOKEN['Blackberry']),
            Device(GCMPushService.type, TOKEN['GCM'])
        ]

        status_dict = pm.send(msg, device_list)

        self.assertTrue(
            status_dict[BBPushService.type].code
            in (1000, 1001, 2001, 2002, 2004, 4001, 21000),
            '\nBlackberry Status Code %i:\n%s\n' %
            (status_dict[BBPushService.type].code,
             status_dict[BBPushService.type].description))

        self.assertTrue(
            status_dict[GCMPushService.type].code in (200, 503),
            '\nGCM Status Code %i:\n' %
            (status_dict[GCMPushService.type].code))
예제 #3
0
 def test_message_set_option(self):
     msg = Message()
     msg.set_option('key', 'value')
     self.assertTrue('key' in msg.options)
     self.assertTrue(msg.options['key'] == 'value')