Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 1 | #!/usr/bin/python2.4 |
Joe Gregorio | f863f7a | 2011-02-24 03:24:44 -0500 | [diff] [blame] | 2 | # -*- coding: utf-8 -*- |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 3 | # |
Joe Gregorio | 6d5e94f | 2010-08-25 23:49:30 -0400 | [diff] [blame] | 4 | # Copyright 2010 Google Inc. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 18 | |
| 19 | """Discovery document tests |
| 20 | |
| 21 | Unit tests for objects created from discovery documents. |
| 22 | """ |
| 23 | |
| 24 | __author__ = 'jcgregorio@google.com (Joe Gregorio)' |
| 25 | |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 26 | import httplib2 |
| 27 | import os |
| 28 | import unittest |
Joe Gregorio | 00cf1d9 | 2010-09-27 09:22:03 -0400 | [diff] [blame] | 29 | import urlparse |
ade@google.com | c5eb46f | 2010-09-27 23:35:39 +0100 | [diff] [blame] | 30 | try: |
| 31 | from urlparse import parse_qs |
| 32 | except ImportError: |
| 33 | from cgi import parse_qs |
Joe Gregorio | 00cf1d9 | 2010-09-27 09:22:03 -0400 | [diff] [blame] | 34 | |
| 35 | from apiclient.discovery import build, key2param |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 36 | from apiclient.http import HttpMock |
Joe Gregorio | f415342 | 2011-03-18 22:45:18 -0400 | [diff] [blame] | 37 | from apiclient.http import tunnel_patch |
| 38 | from apiclient.http import HttpMockSequence |
Joe Gregorio | c0e0fe9 | 2011-03-04 16:16:55 -0500 | [diff] [blame] | 39 | from apiclient.errors import HttpError |
Joe Gregorio | 4939655 | 2011-03-08 10:39:00 -0500 | [diff] [blame] | 40 | from apiclient.errors import InvalidJsonError |
Joe Gregorio | fdf7c80 | 2011-06-30 12:33:38 -0400 | [diff] [blame] | 41 | from apiclient.errors import MediaUploadSizeError |
| 42 | from apiclient.errors import UnacceptableMimeTypeError |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 43 | |
| 44 | |
| 45 | DATA_DIR = os.path.join(os.path.dirname(__file__), 'data') |
| 46 | |
| 47 | def datafile(filename): |
| 48 | return os.path.join(DATA_DIR, filename) |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 49 | |
| 50 | |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 51 | class Utilities(unittest.TestCase): |
| 52 | def test_key2param(self): |
| 53 | self.assertEqual('max_results', key2param('max-results')) |
| 54 | self.assertEqual('x007_bond', key2param('007-bond')) |
| 55 | |
| 56 | |
Joe Gregorio | c0e0fe9 | 2011-03-04 16:16:55 -0500 | [diff] [blame] | 57 | class DiscoveryErrors(unittest.TestCase): |
| 58 | |
| 59 | def test_failed_to_parse_discovery_json(self): |
| 60 | self.http = HttpMock(datafile('malformed.json'), {'status': '200'}) |
| 61 | try: |
| 62 | buzz = build('buzz', 'v1', self.http) |
| 63 | self.fail("should have raised an exception over malformed JSON.") |
Joe Gregorio | 4939655 | 2011-03-08 10:39:00 -0500 | [diff] [blame] | 64 | except InvalidJsonError: |
| 65 | pass |
Joe Gregorio | c0e0fe9 | 2011-03-04 16:16:55 -0500 | [diff] [blame] | 66 | |
| 67 | |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 68 | class Discovery(unittest.TestCase): |
Joe Gregorio | 2379ecc | 2010-10-26 10:51:28 -0400 | [diff] [blame] | 69 | |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 70 | def test_method_error_checking(self): |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 71 | self.http = HttpMock(datafile('buzz.json'), {'status': '200'}) |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 72 | buzz = build('buzz', 'v1', self.http) |
| 73 | |
| 74 | # Missing required parameters |
| 75 | try: |
| 76 | buzz.activities().list() |
| 77 | self.fail() |
| 78 | except TypeError, e: |
| 79 | self.assertTrue('Missing' in str(e)) |
| 80 | |
| 81 | # Parameter doesn't match regex |
| 82 | try: |
Joe Gregorio | bee8683 | 2011-02-22 10:00:19 -0500 | [diff] [blame] | 83 | buzz.activities().list(scope='@myself', userId='me') |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 84 | self.fail() |
| 85 | except TypeError, e: |
Joe Gregorio | ca876e4 | 2011-02-22 19:39:42 -0500 | [diff] [blame] | 86 | self.assertTrue('not an allowed value' in str(e)) |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 87 | |
| 88 | # Parameter doesn't match regex |
| 89 | try: |
| 90 | buzz.activities().list(scope='not@', userId='foo') |
| 91 | self.fail() |
| 92 | except TypeError, e: |
Joe Gregorio | ca876e4 | 2011-02-22 19:39:42 -0500 | [diff] [blame] | 93 | self.assertTrue('not an allowed value' in str(e)) |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 94 | |
| 95 | # Unexpected parameter |
| 96 | try: |
| 97 | buzz.activities().list(flubber=12) |
| 98 | self.fail() |
| 99 | except TypeError, e: |
| 100 | self.assertTrue('unexpected' in str(e)) |
| 101 | |
Joe Gregorio | bee8683 | 2011-02-22 10:00:19 -0500 | [diff] [blame] | 102 | def _check_query_types(self, request): |
| 103 | parsed = urlparse.urlparse(request.uri) |
| 104 | q = parse_qs(parsed[4]) |
| 105 | self.assertEqual(q['q'], ['foo']) |
| 106 | self.assertEqual(q['i'], ['1']) |
| 107 | self.assertEqual(q['n'], ['1.0']) |
| 108 | self.assertEqual(q['b'], ['false']) |
| 109 | self.assertEqual(q['a'], ['[1, 2, 3]']) |
| 110 | self.assertEqual(q['o'], ['{\'a\': 1}']) |
| 111 | self.assertEqual(q['e'], ['bar']) |
| 112 | |
| 113 | def test_type_coercion(self): |
Joe Gregorio | f415342 | 2011-03-18 22:45:18 -0400 | [diff] [blame] | 114 | http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 115 | zoo = build('zoo', 'v1', http) |
Joe Gregorio | bee8683 | 2011-02-22 10:00:19 -0500 | [diff] [blame] | 116 | |
| 117 | request = zoo.query(q="foo", i=1.0, n=1.0, b=0, a=[1,2,3], o={'a':1}, e='bar') |
| 118 | self._check_query_types(request) |
| 119 | request = zoo.query(q="foo", i=1, n=1, b=False, a=[1,2,3], o={'a':1}, e='bar') |
| 120 | self._check_query_types(request) |
Joe Gregorio | f863f7a | 2011-02-24 03:24:44 -0500 | [diff] [blame] | 121 | |
Joe Gregorio | bee8683 | 2011-02-22 10:00:19 -0500 | [diff] [blame] | 122 | request = zoo.query(q="foo", i="1", n="1", b="", a=[1,2,3], o={'a':1}, e='bar') |
| 123 | self._check_query_types(request) |
| 124 | |
Joe Gregorio | 1321795 | 2011-02-22 15:37:38 -0500 | [diff] [blame] | 125 | def test_optional_stack_query_parameters(self): |
Joe Gregorio | f415342 | 2011-03-18 22:45:18 -0400 | [diff] [blame] | 126 | http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 127 | zoo = build('zoo', 'v1', http) |
| 128 | request = zoo.query(trace='html', fields='description') |
Joe Gregorio | 1321795 | 2011-02-22 15:37:38 -0500 | [diff] [blame] | 129 | |
Joe Gregorio | ca876e4 | 2011-02-22 19:39:42 -0500 | [diff] [blame] | 130 | parsed = urlparse.urlparse(request.uri) |
| 131 | q = parse_qs(parsed[4]) |
| 132 | self.assertEqual(q['trace'], ['html']) |
Joe Gregorio | f415342 | 2011-03-18 22:45:18 -0400 | [diff] [blame] | 133 | self.assertEqual(q['fields'], ['description']) |
| 134 | |
| 135 | def test_patch(self): |
| 136 | http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 137 | zoo = build('zoo', 'v1', http) |
| 138 | request = zoo.animals().patch(name='lion', body='{"description": "foo"}') |
| 139 | |
| 140 | self.assertEqual(request.method, 'PATCH') |
| 141 | |
| 142 | def test_tunnel_patch(self): |
| 143 | http = HttpMockSequence([ |
| 144 | ({'status': '200'}, file(datafile('zoo.json'), 'r').read()), |
| 145 | ({'status': '200'}, 'echo_request_headers_as_json'), |
| 146 | ]) |
| 147 | http = tunnel_patch(http) |
| 148 | zoo = build('zoo', 'v1', http) |
| 149 | resp = zoo.animals().patch(name='lion', body='{"description": "foo"}').execute() |
| 150 | |
| 151 | self.assertTrue('x-http-method-override' in resp) |
Joe Gregorio | ca876e4 | 2011-02-22 19:39:42 -0500 | [diff] [blame] | 152 | |
ade@google.com | 850cf55 | 2010-08-20 23:24:56 +0100 | [diff] [blame] | 153 | def test_buzz_resources(self): |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 154 | self.http = HttpMock(datafile('buzz.json'), {'status': '200'}) |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 155 | buzz = build('buzz', 'v1', self.http) |
| 156 | self.assertTrue(getattr(buzz, 'activities')) |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 157 | self.assertTrue(getattr(buzz, 'photos')) |
| 158 | self.assertTrue(getattr(buzz, 'people')) |
| 159 | self.assertTrue(getattr(buzz, 'groups')) |
| 160 | self.assertTrue(getattr(buzz, 'comments')) |
| 161 | self.assertTrue(getattr(buzz, 'related')) |
| 162 | |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 163 | def test_auth(self): |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 164 | self.http = HttpMock(datafile('buzz.json'), {'status': '200'}) |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 165 | buzz = build('buzz', 'v1', self.http) |
| 166 | auth = buzz.auth_discovery() |
| 167 | self.assertTrue('request' in auth) |
| 168 | |
Joe Gregorio | 2379ecc | 2010-10-26 10:51:28 -0400 | [diff] [blame] | 169 | def test_full_featured(self): |
| 170 | # Zoo should exercise all discovery facets |
| 171 | # and should also have no future.json file. |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 172 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
Joe Gregorio | 2379ecc | 2010-10-26 10:51:28 -0400 | [diff] [blame] | 173 | zoo = build('zoo', 'v1', self.http) |
| 174 | self.assertTrue(getattr(zoo, 'animals')) |
Joe Gregorio | f863f7a | 2011-02-24 03:24:44 -0500 | [diff] [blame] | 175 | |
Joe Gregorio | f415342 | 2011-03-18 22:45:18 -0400 | [diff] [blame] | 176 | request = zoo.animals().list(name='bat', projection="full") |
Joe Gregorio | 2379ecc | 2010-10-26 10:51:28 -0400 | [diff] [blame] | 177 | parsed = urlparse.urlparse(request.uri) |
| 178 | q = parse_qs(parsed[4]) |
| 179 | self.assertEqual(q['name'], ['bat']) |
Joe Gregorio | f415342 | 2011-03-18 22:45:18 -0400 | [diff] [blame] | 180 | self.assertEqual(q['projection'], ['full']) |
Joe Gregorio | 2379ecc | 2010-10-26 10:51:28 -0400 | [diff] [blame] | 181 | |
Joe Gregorio | 3fada33 | 2011-01-07 17:07:45 -0500 | [diff] [blame] | 182 | def test_nested_resources(self): |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 183 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
Joe Gregorio | 3fada33 | 2011-01-07 17:07:45 -0500 | [diff] [blame] | 184 | zoo = build('zoo', 'v1', self.http) |
| 185 | self.assertTrue(getattr(zoo, 'animals')) |
| 186 | request = zoo.my().favorites().list(max_results="5") |
| 187 | parsed = urlparse.urlparse(request.uri) |
| 188 | q = parse_qs(parsed[4]) |
| 189 | self.assertEqual(q['max-results'], ['5']) |
| 190 | |
Joe Gregorio | d92897c | 2011-07-07 11:44:56 -0400 | [diff] [blame] | 191 | def test_methods_with_reserved_names(self): |
| 192 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 193 | zoo = build('zoo', 'v1', self.http) |
| 194 | self.assertTrue(getattr(zoo, 'animals')) |
| 195 | request = zoo.global_().print_().assert_(max_results="5") |
| 196 | parsed = urlparse.urlparse(request.uri) |
| 197 | self.assertEqual(parsed[2], '/zoo/global/print/assert') |
| 198 | |
Joe Gregorio | 7a6df3a | 2011-01-31 21:55:21 -0500 | [diff] [blame] | 199 | def test_top_level_functions(self): |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 200 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
Joe Gregorio | 7a6df3a | 2011-01-31 21:55:21 -0500 | [diff] [blame] | 201 | zoo = build('zoo', 'v1', self.http) |
| 202 | self.assertTrue(getattr(zoo, 'query')) |
| 203 | request = zoo.query(q="foo") |
| 204 | parsed = urlparse.urlparse(request.uri) |
| 205 | q = parse_qs(parsed[4]) |
| 206 | self.assertEqual(q['q'], ['foo']) |
Joe Gregorio | 2379ecc | 2010-10-26 10:51:28 -0400 | [diff] [blame] | 207 | |
Joe Gregorio | fdf7c80 | 2011-06-30 12:33:38 -0400 | [diff] [blame] | 208 | def test_simple_media_uploads(self): |
| 209 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 210 | zoo = build('zoo', 'v1', self.http) |
| 211 | doc = getattr(zoo.animals().insert, '__doc__') |
| 212 | self.assertTrue('media_body' in doc) |
| 213 | |
Joe Gregorio | 84d3c1f | 2011-07-25 10:39:45 -0400 | [diff] [blame] | 214 | def test_simple_media_upload_no_max_size_provided(self): |
| 215 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 216 | zoo = build('zoo', 'v1', self.http) |
| 217 | request = zoo.animals().crossbreed(media_body=datafile('small.png')) |
| 218 | self.assertEquals('image/png', request.headers['content-type']) |
| 219 | self.assertEquals('PNG', request.body[1:4]) |
| 220 | |
Joe Gregorio | fdf7c80 | 2011-06-30 12:33:38 -0400 | [diff] [blame] | 221 | def test_simple_media_raise_correct_exceptions(self): |
| 222 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 223 | zoo = build('zoo', 'v1', self.http) |
| 224 | |
| 225 | try: |
| 226 | zoo.animals().insert(media_body=datafile('smiley.png')) |
| 227 | self.fail("should throw exception if media is too large.") |
| 228 | except MediaUploadSizeError: |
| 229 | pass |
| 230 | |
| 231 | try: |
| 232 | zoo.animals().insert(media_body=datafile('small.jpg')) |
| 233 | self.fail("should throw exception if mimetype is unacceptable.") |
| 234 | except UnacceptableMimeTypeError: |
| 235 | pass |
| 236 | |
| 237 | def test_simple_media_good_upload(self): |
| 238 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 239 | zoo = build('zoo', 'v1', self.http) |
| 240 | |
| 241 | request = zoo.animals().insert(media_body=datafile('small.png')) |
| 242 | self.assertEquals('image/png', request.headers['content-type']) |
| 243 | self.assertEquals('PNG', request.body[1:4]) |
| 244 | |
| 245 | def test_multipart_media_raise_correct_exceptions(self): |
| 246 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 247 | zoo = build('zoo', 'v1', self.http) |
| 248 | |
| 249 | try: |
| 250 | zoo.animals().insert(media_body=datafile('smiley.png'), body={}) |
| 251 | self.fail("should throw exception if media is too large.") |
| 252 | except MediaUploadSizeError: |
| 253 | pass |
| 254 | |
| 255 | try: |
| 256 | zoo.animals().insert(media_body=datafile('small.jpg'), body={}) |
| 257 | self.fail("should throw exception if mimetype is unacceptable.") |
| 258 | except UnacceptableMimeTypeError: |
| 259 | pass |
| 260 | |
| 261 | def test_multipart_media_good_upload(self): |
| 262 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 263 | zoo = build('zoo', 'v1', self.http) |
| 264 | |
| 265 | request = zoo.animals().insert(media_body=datafile('small.png'), body={}) |
| 266 | self.assertTrue(request.headers['content-type'].startswith('multipart/related')) |
| 267 | self.assertEquals('--==', request.body[0:4]) |
| 268 | |
| 269 | def test_media_capable_method_without_media(self): |
| 270 | self.http = HttpMock(datafile('zoo.json'), {'status': '200'}) |
| 271 | zoo = build('zoo', 'v1', self.http) |
| 272 | |
| 273 | request = zoo.animals().insert(body={}) |
| 274 | self.assertTrue(request.headers['content-type'], 'application/json') |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 275 | |
| 276 | class Next(unittest.TestCase): |
Joe Gregorio | c935907 | 2010-10-25 15:26:13 -0400 | [diff] [blame] | 277 | def test_next_for_people_liked(self): |
Joe Gregorio | 3c676f9 | 2011-07-25 10:38:14 -0400 | [diff] [blame] | 278 | """Legacy test for Buzz _next support.""" |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 279 | self.http = HttpMock(datafile('buzz.json'), {'status': '200'}) |
Joe Gregorio | c935907 | 2010-10-25 15:26:13 -0400 | [diff] [blame] | 280 | buzz = build('buzz', 'v1', self.http) |
| 281 | people = {'links': |
Joe Gregorio | c5c5a37 | 2010-09-22 11:42:32 -0400 | [diff] [blame] | 282 | {'next': |
| 283 | [{'href': 'http://www.googleapis.com/next-link'}]}} |
Joe Gregorio | c935907 | 2010-10-25 15:26:13 -0400 | [diff] [blame] | 284 | request = buzz.people().liked_next(people) |
| 285 | self.assertEqual(request.uri, 'http://www.googleapis.com/next-link') |
Joe Gregorio | 00cf1d9 | 2010-09-27 09:22:03 -0400 | [diff] [blame] | 286 | |
Joe Gregorio | 3c676f9 | 2011-07-25 10:38:14 -0400 | [diff] [blame] | 287 | def test_next_successful_none_on_no_next_page_token(self): |
| 288 | self.http = HttpMock(datafile('tasks.json'), {'status': '200'}) |
| 289 | tasks = build('tasks', 'v1', self.http) |
| 290 | request = tasks.tasklists().list() |
| 291 | self.assertEqual(None, tasks.tasklists().list_next(request, {})) |
| 292 | |
| 293 | def test_next_successful_with_next_page_token(self): |
| 294 | self.http = HttpMock(datafile('tasks.json'), {'status': '200'}) |
| 295 | tasks = build('tasks', 'v1', self.http) |
| 296 | request = tasks.tasklists().list() |
| 297 | next_request = tasks.tasklists().list_next(request, {'nextPageToken': '123abc'}) |
| 298 | parsed = list(urlparse.urlparse(next_request.uri)) |
| 299 | q = parse_qs(parsed[4]) |
| 300 | self.assertEqual(q['pageToken'][0], '123abc') |
| 301 | |
Joe Gregorio | 555f33c | 2011-08-19 14:56:07 -0400 | [diff] [blame^] | 302 | def test_next_with_method_with_no_properties(self): |
| 303 | self.http = HttpMock(datafile('latitude.json'), {'status': '200'}) |
| 304 | service = build('latitude', 'v1', self.http) |
| 305 | request = service.currentLocation().get() |
Joe Gregorio | 00cf1d9 | 2010-09-27 09:22:03 -0400 | [diff] [blame] | 306 | |
| 307 | class DeveloperKey(unittest.TestCase): |
| 308 | def test_param(self): |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 309 | self.http = HttpMock(datafile('buzz.json'), {'status': '200'}) |
Joe Gregorio | 00cf1d9 | 2010-09-27 09:22:03 -0400 | [diff] [blame] | 310 | buzz = build('buzz', 'v1', self.http, developerKey='foobie_bletch') |
| 311 | activities = {'links': |
| 312 | {'next': |
| 313 | [{'href': 'http://www.googleapis.com/next-link'}]}} |
| 314 | request = buzz.activities().list_next(activities) |
| 315 | parsed = urlparse.urlparse(request.uri) |
ade@google.com | c5eb46f | 2010-09-27 23:35:39 +0100 | [diff] [blame] | 316 | q = parse_qs(parsed[4]) |
Joe Gregorio | 00cf1d9 | 2010-09-27 09:22:03 -0400 | [diff] [blame] | 317 | self.assertEqual(q['key'], ['foobie_bletch']) |
| 318 | |
Joe Gregorio | c935907 | 2010-10-25 15:26:13 -0400 | [diff] [blame] | 319 | def test_next_for_activities_list(self): |
Joe Gregorio | cb8103d | 2011-02-11 23:20:52 -0500 | [diff] [blame] | 320 | self.http = HttpMock(datafile('buzz.json'), {'status': '200'}) |
Joe Gregorio | c935907 | 2010-10-25 15:26:13 -0400 | [diff] [blame] | 321 | buzz = build('buzz', 'v1', self.http, developerKey='foobie_bletch') |
| 322 | activities = {'links': |
ade@google.com | 2ab0de7 | 2010-09-27 23:26:54 +0100 | [diff] [blame] | 323 | {'next': |
| 324 | [{'href': 'http://www.googleapis.com/next-link'}]}} |
Joe Gregorio | c935907 | 2010-10-25 15:26:13 -0400 | [diff] [blame] | 325 | request = buzz.activities().list_next(activities) |
| 326 | self.assertEqual(request.uri, |
| 327 | 'http://www.googleapis.com/next-link?key=foobie_bletch') |
| 328 | |
Joe Gregorio | ba9ea7f | 2010-08-19 15:49:04 -0400 | [diff] [blame] | 329 | |
| 330 | if __name__ == '__main__': |
| 331 | unittest.main() |