示例#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)