示例#1
0
 def test_send(self):
     request = SubscriptionBatchRequest('abc', 'broadcasts',
                                        SubscriptionActionType.REMOVE)
     response = request.send('abcd123')
     self.assertIsNotNone(response.subscribers)
     self.assertEqual(len(response.subscribers), 1)
     self.assertIsNone(response.error)
示例#2
0
 def test_token_value_len(self):
     max = 1000
     with self.assertRaises(ValueError):
         SubscriptionBatchRequest(['abc' for _ in xrange(max + 1)],
                                  'broadcasts', SubscriptionActionType.ADD)
     SubscriptionBatchRequest(['abc' for _ in xrange(max)], 'broadcasts',
                              SubscriptionActionType.ADD)
示例#3
0
 def test_str(self):
     request = SubscriptionBatchRequest('abc', 'broadcasts',
                                        SubscriptionActionType.REMOVE)
     self.assertEqual(
         str(request),
         "SubscriptionBatchRequest(tokens=['abc'], topic=/topics/broadcasts, method=v1:batchRemove)"
     )
示例#4
0
 def test_iid_info_url(self):
     for action_type in SubscriptionActionType.batch_actions:
         method = SubscriptionActionType.BATCH_METHODS[action_type]
         request = SubscriptionBatchRequest('abc', 'broadcasts',
                                            action_type)
         self.assertEqual(
             request._batch_url,
             'https://iid.googleapis.com/iid/{}'.format(method))
 def test_send(self):
     request = SubscriptionBatchRequest('abc', 'broadcasts', SubscriptionActionType.REMOVE)
     response = request.send('abcd123')
     self.assertIsNotNone(response.subscribers)
     self.assertEqual(len(response.subscribers), 1)
     self.assertIsNone(response.error)
 def test_send_api_key_empty(self):
     request = SubscriptionBatchRequest('abc', 'broadcasts', SubscriptionActionType.REMOVE)
     with self.assertRaises(ValueError):
         response = request.send('')
示例#7
0
 def test_topic(self):
     request = SubscriptionBatchRequest('abc', '/topics/broadcasts',
                                        SubscriptionActionType.ADD)
     self.assertEqual(request.topic, '/topics/broadcasts')
示例#8
0
 def test_token_value_mixed(self):
     with self.assertRaises(ValueError):
         SubscriptionBatchRequest(['abc', 2], 'broadcasts',
                                  SubscriptionActionType.ADD)
示例#9
0
 def test_tokens_type(self):
     with self.assertRaises(ValueError):
         SubscriptionBatchRequest([], 'broadcasts',
                                  SubscriptionActionType.ADD)
示例#10
0
 def test_token_value_none(self):
     with self.assertRaises(TypeError):
         SubscriptionBatchRequest(None, 'broadcasts',
                                  SubscriptionActionType.ADD)
示例#11
0
 def test_tokens(self):
     request = SubscriptionBatchRequest('abc', 'broadcasts',
                                        SubscriptionActionType.ADD)
     self.assertEqual(request.tokens, ['abc'])
示例#12
0
 def test_send_api_key_empty(self):
     request = SubscriptionBatchRequest('abc', 'broadcasts',
                                        SubscriptionActionType.REMOVE)
     with self.assertRaises(ValueError):
         response = request.send('')
示例#13
0
 def test_action_type(self):
     with self.assertRaises(ValueError):
         SubscriptionBatchRequest('abc', 'broadcasts', -1)
示例#14
0
 def test_action_type(self):
     SubscriptionBatchRequest('abc', 'broadcasts',
                              SubscriptionActionType.ADD)
示例#15
0
 def test_topic_empty(self):
     with self.assertRaises(ValueError):
         SubscriptionBatchRequest('abc', '', SubscriptionActionType.ADD)
示例#16
0
 def test_topic_none(self):
     with self.assertRaises(TypeError):
         SubscriptionBatchRequest('abc', None, SubscriptionActionType.ADD)