Пример #1
0
 def test_write_header_args_escape(self):
     c = push.Channel(channel_type='my_channel_type',
                      channel_args={'a': 'b%c'})
     headers = {}
     c.write_header(headers)
     self.assertEqual('my_channel_type?a=b%25c',
                      headers['X-GOOG-SUBSCRIBE'])
Пример #2
0
 def test_non_get_error(self):
     m = model.JsonModel()
     request = http.HttpRequest(
         None,
         m.response,
         'https://www.googleapis.com/someapi/v1/collection/?foo=bar',
         method='POST',
         body='{}',
         headers={'content-type': 'application/json'})
     c = push.Channel('my_channel', {})
     self.assertRaises(push.InvalidSubscriptionRequestError,
                       push.Subscription.for_request, request, c)
Пример #3
0
 def test_request_is_post(self):
     m = model.JsonModel()
     request = http.HttpRequest(
         None,
         m.response,
         'https://www.googleapis.com/someapi/v1/collection/?foo=bar',
         method='GET',
         body='{}',
         headers={'content-type': 'application/json'})
     c = push.Channel('my_channel', {})
     push.Subscription.for_request(request, c)
     self.assertEqual('POST', request.method)
Пример #4
0
 def test_do_subscribe(self):
     m = model.JsonModel()
     request = http.HttpRequest(
         None,
         m.response,
         'https://www.googleapis.com/someapi/v1/collection/?foo=bar',
         method='GET',
         body='{}',
         headers={'content-type': 'application/json'})
     h = http.HttpMockSequence([({
         'status': 200,
         'X-Goog-Subscription-ID': 'my_subscription'
     }, '{}')])
     c = push.Channel('my_channel', {})
     s = push.Subscription.for_request(request, c)
     request.execute(http=h)
     self.assertEqual('my_subscription', s.subscription_id)
Пример #5
0
 def test_write_header_noargs(self):
     c = push.Channel(channel_type='my_channel_type', channel_args={})
     headers = {}
     c.write_header(headers)
     self.assertEqual('my_channel_type?', headers['X-GOOG-SUBSCRIBE'])
Пример #6
0
 def test_as_header_value_args_escape(self):
     c = push.Channel(channel_type='my_channel_type',
                      channel_args={'a': 'b%c'})
     self.assertEqual('my_channel_type?a=b%25c', c.as_header_value())
Пример #7
0
 def test_as_header_value_noargs(self):
     c = push.Channel(channel_type='my_channel_type', channel_args={})
     self.assertEqual('my_channel_type?', c.as_header_value())
Пример #8
0
 def test_creation_args(self):
     c = push.Channel(channel_type='my_channel_type',
                      channel_args={'a': 'b'})
     self.assertEqual('my_channel_type', c.channel_type)
     self.assertEqual({'a': 'b'}, c.channel_args)