OLD | NEW |
1 library googleapis_beta.taskqueue.v1beta2.test; | 1 library googleapis_beta.taskqueue.v1beta2.test; |
2 | 2 |
3 import "dart:core" as core; | 3 import "dart:core" as core; |
4 import "dart:collection" as collection; | 4 import "dart:collection" as collection; |
5 import "dart:async" as async; | 5 import "dart:async" as async; |
6 import "dart:convert" as convert; | 6 import "dart:convert" as convert; |
7 | 7 |
8 import 'package:http/http.dart' as http; | 8 import 'package:http/http.dart' as http; |
9 import 'package:http/testing.dart' as http_testing; | 9 import 'package:http/testing.dart' as http_testing; |
10 import 'package:unittest/unittest.dart' as unittest; | 10 import 'package:unittest/unittest.dart' as unittest; |
11 import 'package:googleapis_beta/common/common.dart' as common; | |
12 import 'package:googleapis_beta/src/common_internal.dart' as common_internal; | |
13 import '../common/common_internal_test.dart' as common_test; | |
14 | 11 |
15 import 'package:googleapis_beta/taskqueue/v1beta2.dart' as api; | 12 import 'package:googleapis_beta/taskqueue/v1beta2.dart' as api; |
16 | 13 |
| 14 class HttpServerMock extends http.BaseClient { |
| 15 core.Function _callback; |
| 16 core.bool _expectJson; |
17 | 17 |
| 18 void register(core.Function callback, core.bool expectJson) { |
| 19 _callback = callback; |
| 20 _expectJson = expectJson; |
| 21 } |
| 22 |
| 23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { |
| 24 if (_expectJson) { |
| 25 return request.finalize() |
| 26 .transform(convert.UTF8.decoder) |
| 27 .join('') |
| 28 .then((core.String jsonString) { |
| 29 if (jsonString.isEmpty) { |
| 30 return _callback(request, null); |
| 31 } else { |
| 32 return _callback(request, convert.JSON.decode(jsonString)); |
| 33 } |
| 34 }); |
| 35 } else { |
| 36 var stream = request.finalize(); |
| 37 if (stream == null) { |
| 38 return _callback(request, []); |
| 39 } else { |
| 40 return stream.toBytes().then((data) { |
| 41 return _callback(request, data); |
| 42 }); |
| 43 } |
| 44 } |
| 45 } |
| 46 } |
| 47 |
| 48 http.StreamedResponse stringResponse( |
| 49 core.int status, core.Map headers, core.String body) { |
| 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); |
| 51 return new http.StreamedResponse(stream, status, headers: headers); |
| 52 } |
18 | 53 |
19 core.int buildCounterTask = 0; | 54 core.int buildCounterTask = 0; |
20 buildTask() { | 55 buildTask() { |
21 var o = new api.Task(); | 56 var o = new api.Task(); |
22 buildCounterTask++; | 57 buildCounterTask++; |
23 if (buildCounterTask < 3) { | 58 if (buildCounterTask < 3) { |
24 o.enqueueTimestamp = "foo"; | 59 o.enqueueTimestamp = "foo"; |
25 o.id = "foo"; | 60 o.id = "foo"; |
26 o.kind = "foo"; | 61 o.kind = "foo"; |
27 o.leaseTimestamp = "foo"; | 62 o.leaseTimestamp = "foo"; |
(...skipping 14 matching lines...) Expand all Loading... |
42 unittest.expect(o.kind, unittest.equals('foo')); | 77 unittest.expect(o.kind, unittest.equals('foo')); |
43 unittest.expect(o.leaseTimestamp, unittest.equals('foo')); | 78 unittest.expect(o.leaseTimestamp, unittest.equals('foo')); |
44 unittest.expect(o.payloadBase64, unittest.equals('foo')); | 79 unittest.expect(o.payloadBase64, unittest.equals('foo')); |
45 unittest.expect(o.queueName, unittest.equals('foo')); | 80 unittest.expect(o.queueName, unittest.equals('foo')); |
46 unittest.expect(o.retryCount, unittest.equals(42)); | 81 unittest.expect(o.retryCount, unittest.equals(42)); |
47 unittest.expect(o.tag, unittest.equals('foo')); | 82 unittest.expect(o.tag, unittest.equals('foo')); |
48 } | 83 } |
49 buildCounterTask--; | 84 buildCounterTask--; |
50 } | 85 } |
51 | 86 |
52 buildUnnamed1628() { | 87 buildUnnamed1816() { |
53 var o = new core.List<core.String>(); | 88 var o = new core.List<core.String>(); |
54 o.add("foo"); | 89 o.add("foo"); |
55 o.add("foo"); | 90 o.add("foo"); |
56 return o; | 91 return o; |
57 } | 92 } |
58 | 93 |
59 checkUnnamed1628(core.List<core.String> o) { | 94 checkUnnamed1816(core.List<core.String> o) { |
60 unittest.expect(o, unittest.hasLength(2)); | 95 unittest.expect(o, unittest.hasLength(2)); |
61 unittest.expect(o[0], unittest.equals('foo')); | 96 unittest.expect(o[0], unittest.equals('foo')); |
62 unittest.expect(o[1], unittest.equals('foo')); | 97 unittest.expect(o[1], unittest.equals('foo')); |
63 } | 98 } |
64 | 99 |
65 buildUnnamed1629() { | 100 buildUnnamed1817() { |
66 var o = new core.List<core.String>(); | 101 var o = new core.List<core.String>(); |
67 o.add("foo"); | 102 o.add("foo"); |
68 o.add("foo"); | 103 o.add("foo"); |
69 return o; | 104 return o; |
70 } | 105 } |
71 | 106 |
72 checkUnnamed1629(core.List<core.String> o) { | 107 checkUnnamed1817(core.List<core.String> o) { |
73 unittest.expect(o, unittest.hasLength(2)); | 108 unittest.expect(o, unittest.hasLength(2)); |
74 unittest.expect(o[0], unittest.equals('foo')); | 109 unittest.expect(o[0], unittest.equals('foo')); |
75 unittest.expect(o[1], unittest.equals('foo')); | 110 unittest.expect(o[1], unittest.equals('foo')); |
76 } | 111 } |
77 | 112 |
78 buildUnnamed1630() { | 113 buildUnnamed1818() { |
79 var o = new core.List<core.String>(); | 114 var o = new core.List<core.String>(); |
80 o.add("foo"); | 115 o.add("foo"); |
81 o.add("foo"); | 116 o.add("foo"); |
82 return o; | 117 return o; |
83 } | 118 } |
84 | 119 |
85 checkUnnamed1630(core.List<core.String> o) { | 120 checkUnnamed1818(core.List<core.String> o) { |
86 unittest.expect(o, unittest.hasLength(2)); | 121 unittest.expect(o, unittest.hasLength(2)); |
87 unittest.expect(o[0], unittest.equals('foo')); | 122 unittest.expect(o[0], unittest.equals('foo')); |
88 unittest.expect(o[1], unittest.equals('foo')); | 123 unittest.expect(o[1], unittest.equals('foo')); |
89 } | 124 } |
90 | 125 |
91 core.int buildCounterTaskQueueAcl = 0; | 126 core.int buildCounterTaskQueueAcl = 0; |
92 buildTaskQueueAcl() { | 127 buildTaskQueueAcl() { |
93 var o = new api.TaskQueueAcl(); | 128 var o = new api.TaskQueueAcl(); |
94 buildCounterTaskQueueAcl++; | 129 buildCounterTaskQueueAcl++; |
95 if (buildCounterTaskQueueAcl < 3) { | 130 if (buildCounterTaskQueueAcl < 3) { |
96 o.adminEmails = buildUnnamed1628(); | 131 o.adminEmails = buildUnnamed1816(); |
97 o.consumerEmails = buildUnnamed1629(); | 132 o.consumerEmails = buildUnnamed1817(); |
98 o.producerEmails = buildUnnamed1630(); | 133 o.producerEmails = buildUnnamed1818(); |
99 } | 134 } |
100 buildCounterTaskQueueAcl--; | 135 buildCounterTaskQueueAcl--; |
101 return o; | 136 return o; |
102 } | 137 } |
103 | 138 |
104 checkTaskQueueAcl(api.TaskQueueAcl o) { | 139 checkTaskQueueAcl(api.TaskQueueAcl o) { |
105 buildCounterTaskQueueAcl++; | 140 buildCounterTaskQueueAcl++; |
106 if (buildCounterTaskQueueAcl < 3) { | 141 if (buildCounterTaskQueueAcl < 3) { |
107 checkUnnamed1628(o.adminEmails); | 142 checkUnnamed1816(o.adminEmails); |
108 checkUnnamed1629(o.consumerEmails); | 143 checkUnnamed1817(o.consumerEmails); |
109 checkUnnamed1630(o.producerEmails); | 144 checkUnnamed1818(o.producerEmails); |
110 } | 145 } |
111 buildCounterTaskQueueAcl--; | 146 buildCounterTaskQueueAcl--; |
112 } | 147 } |
113 | 148 |
114 core.int buildCounterTaskQueueStats = 0; | 149 core.int buildCounterTaskQueueStats = 0; |
115 buildTaskQueueStats() { | 150 buildTaskQueueStats() { |
116 var o = new api.TaskQueueStats(); | 151 var o = new api.TaskQueueStats(); |
117 buildCounterTaskQueueStats++; | 152 buildCounterTaskQueueStats++; |
118 if (buildCounterTaskQueueStats < 3) { | 153 if (buildCounterTaskQueueStats < 3) { |
119 o.leasedLastHour = "foo"; | 154 o.leasedLastHour = "foo"; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 if (buildCounterTaskQueue < 3) { | 191 if (buildCounterTaskQueue < 3) { |
157 checkTaskQueueAcl(o.acl); | 192 checkTaskQueueAcl(o.acl); |
158 unittest.expect(o.id, unittest.equals('foo')); | 193 unittest.expect(o.id, unittest.equals('foo')); |
159 unittest.expect(o.kind, unittest.equals('foo')); | 194 unittest.expect(o.kind, unittest.equals('foo')); |
160 unittest.expect(o.maxLeases, unittest.equals(42)); | 195 unittest.expect(o.maxLeases, unittest.equals(42)); |
161 checkTaskQueueStats(o.stats); | 196 checkTaskQueueStats(o.stats); |
162 } | 197 } |
163 buildCounterTaskQueue--; | 198 buildCounterTaskQueue--; |
164 } | 199 } |
165 | 200 |
166 buildUnnamed1631() { | 201 buildUnnamed1819() { |
167 var o = new core.List<api.Task>(); | 202 var o = new core.List<api.Task>(); |
168 o.add(buildTask()); | 203 o.add(buildTask()); |
169 o.add(buildTask()); | 204 o.add(buildTask()); |
170 return o; | 205 return o; |
171 } | 206 } |
172 | 207 |
173 checkUnnamed1631(core.List<api.Task> o) { | 208 checkUnnamed1819(core.List<api.Task> o) { |
174 unittest.expect(o, unittest.hasLength(2)); | 209 unittest.expect(o, unittest.hasLength(2)); |
175 checkTask(o[0]); | 210 checkTask(o[0]); |
176 checkTask(o[1]); | 211 checkTask(o[1]); |
177 } | 212 } |
178 | 213 |
179 core.int buildCounterTasks = 0; | 214 core.int buildCounterTasks = 0; |
180 buildTasks() { | 215 buildTasks() { |
181 var o = new api.Tasks(); | 216 var o = new api.Tasks(); |
182 buildCounterTasks++; | 217 buildCounterTasks++; |
183 if (buildCounterTasks < 3) { | 218 if (buildCounterTasks < 3) { |
184 o.items = buildUnnamed1631(); | 219 o.items = buildUnnamed1819(); |
185 o.kind = "foo"; | 220 o.kind = "foo"; |
186 } | 221 } |
187 buildCounterTasks--; | 222 buildCounterTasks--; |
188 return o; | 223 return o; |
189 } | 224 } |
190 | 225 |
191 checkTasks(api.Tasks o) { | 226 checkTasks(api.Tasks o) { |
192 buildCounterTasks++; | 227 buildCounterTasks++; |
193 if (buildCounterTasks < 3) { | 228 if (buildCounterTasks < 3) { |
194 checkUnnamed1631(o.items); | 229 checkUnnamed1819(o.items); |
195 unittest.expect(o.kind, unittest.equals('foo')); | 230 unittest.expect(o.kind, unittest.equals('foo')); |
196 } | 231 } |
197 buildCounterTasks--; | 232 buildCounterTasks--; |
198 } | 233 } |
199 | 234 |
200 buildUnnamed1632() { | 235 buildUnnamed1820() { |
201 var o = new core.List<api.Task>(); | 236 var o = new core.List<api.Task>(); |
202 o.add(buildTask()); | 237 o.add(buildTask()); |
203 o.add(buildTask()); | 238 o.add(buildTask()); |
204 return o; | 239 return o; |
205 } | 240 } |
206 | 241 |
207 checkUnnamed1632(core.List<api.Task> o) { | 242 checkUnnamed1820(core.List<api.Task> o) { |
208 unittest.expect(o, unittest.hasLength(2)); | 243 unittest.expect(o, unittest.hasLength(2)); |
209 checkTask(o[0]); | 244 checkTask(o[0]); |
210 checkTask(o[1]); | 245 checkTask(o[1]); |
211 } | 246 } |
212 | 247 |
213 core.int buildCounterTasks2 = 0; | 248 core.int buildCounterTasks2 = 0; |
214 buildTasks2() { | 249 buildTasks2() { |
215 var o = new api.Tasks2(); | 250 var o = new api.Tasks2(); |
216 buildCounterTasks2++; | 251 buildCounterTasks2++; |
217 if (buildCounterTasks2 < 3) { | 252 if (buildCounterTasks2 < 3) { |
218 o.items = buildUnnamed1632(); | 253 o.items = buildUnnamed1820(); |
219 o.kind = "foo"; | 254 o.kind = "foo"; |
220 } | 255 } |
221 buildCounterTasks2--; | 256 buildCounterTasks2--; |
222 return o; | 257 return o; |
223 } | 258 } |
224 | 259 |
225 checkTasks2(api.Tasks2 o) { | 260 checkTasks2(api.Tasks2 o) { |
226 buildCounterTasks2++; | 261 buildCounterTasks2++; |
227 if (buildCounterTasks2 < 3) { | 262 if (buildCounterTasks2 < 3) { |
228 checkUnnamed1632(o.items); | 263 checkUnnamed1820(o.items); |
229 unittest.expect(o.kind, unittest.equals('foo')); | 264 unittest.expect(o.kind, unittest.equals('foo')); |
230 } | 265 } |
231 buildCounterTasks2--; | 266 buildCounterTasks2--; |
232 } | 267 } |
233 | 268 |
234 | 269 |
235 main() { | 270 main() { |
236 unittest.group("obj-schema-Task", () { | 271 unittest.group("obj-schema-Task", () { |
237 unittest.test("to-json--from-json", () { | 272 unittest.test("to-json--from-json", () { |
238 var o = buildTask(); | 273 var o = buildTask(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 var o = buildTasks2(); | 318 var o = buildTasks2(); |
284 var od = new api.Tasks2.fromJson(o.toJson()); | 319 var od = new api.Tasks2.fromJson(o.toJson()); |
285 checkTasks2(od); | 320 checkTasks2(od); |
286 }); | 321 }); |
287 }); | 322 }); |
288 | 323 |
289 | 324 |
290 unittest.group("resource-TaskqueuesResourceApi", () { | 325 unittest.group("resource-TaskqueuesResourceApi", () { |
291 unittest.test("method--get", () { | 326 unittest.test("method--get", () { |
292 | 327 |
293 var mock = new common_test.HttpServerMock(); | 328 var mock = new HttpServerMock(); |
294 api.TaskqueuesResourceApi res = new api.TaskqueueApi(mock).taskqueues; | 329 api.TaskqueuesResourceApi res = new api.TaskqueueApi(mock).taskqueues; |
295 var arg_project = "foo"; | 330 var arg_project = "foo"; |
296 var arg_taskqueue = "foo"; | 331 var arg_taskqueue = "foo"; |
297 var arg_getStats = true; | 332 var arg_getStats = true; |
298 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 333 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
299 var path = (req.url).path; | 334 var path = (req.url).path; |
300 var pathOffset = 0; | 335 var pathOffset = 0; |
301 var index; | 336 var index; |
302 var subPart; | 337 var subPart; |
303 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 338 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
(...skipping 15 matching lines...) Expand all Loading... |
319 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 354 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
320 } | 355 } |
321 } | 356 } |
322 unittest.expect(queryMap["getStats"].first, unittest.equals("$arg_getSta
ts")); | 357 unittest.expect(queryMap["getStats"].first, unittest.equals("$arg_getSta
ts")); |
323 | 358 |
324 | 359 |
325 var h = { | 360 var h = { |
326 "content-type" : "application/json; charset=utf-8", | 361 "content-type" : "application/json; charset=utf-8", |
327 }; | 362 }; |
328 var resp = convert.JSON.encode(buildTaskQueue()); | 363 var resp = convert.JSON.encode(buildTaskQueue()); |
329 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 364 return new async.Future.value(stringResponse(200, h, resp)); |
330 }), true); | 365 }), true); |
331 res.get(arg_project, arg_taskqueue, getStats: arg_getStats).then(unittest.
expectAsync(((api.TaskQueue response) { | 366 res.get(arg_project, arg_taskqueue, getStats: arg_getStats).then(unittest.
expectAsync(((api.TaskQueue response) { |
332 checkTaskQueue(response); | 367 checkTaskQueue(response); |
333 }))); | 368 }))); |
334 }); | 369 }); |
335 | 370 |
336 }); | 371 }); |
337 | 372 |
338 | 373 |
339 unittest.group("resource-TasksResourceApi", () { | 374 unittest.group("resource-TasksResourceApi", () { |
340 unittest.test("method--delete", () { | 375 unittest.test("method--delete", () { |
341 | 376 |
342 var mock = new common_test.HttpServerMock(); | 377 var mock = new HttpServerMock(); |
343 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; | 378 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; |
344 var arg_project = "foo"; | 379 var arg_project = "foo"; |
345 var arg_taskqueue = "foo"; | 380 var arg_taskqueue = "foo"; |
346 var arg_task = "foo"; | 381 var arg_task = "foo"; |
347 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 382 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
348 var path = (req.url).path; | 383 var path = (req.url).path; |
349 var pathOffset = 0; | 384 var pathOffset = 0; |
350 var index; | 385 var index; |
351 var subPart; | 386 var subPart; |
352 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 387 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
(...skipping 14 matching lines...) Expand all Loading... |
367 var keyvalue = part.split("="); | 402 var keyvalue = part.split("="); |
368 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 403 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
369 } | 404 } |
370 } | 405 } |
371 | 406 |
372 | 407 |
373 var h = { | 408 var h = { |
374 "content-type" : "application/json; charset=utf-8", | 409 "content-type" : "application/json; charset=utf-8", |
375 }; | 410 }; |
376 var resp = ""; | 411 var resp = ""; |
377 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 412 return new async.Future.value(stringResponse(200, h, resp)); |
378 }), true); | 413 }), true); |
379 res.delete(arg_project, arg_taskqueue, arg_task).then(unittest.expectAsync
((_) {})); | 414 res.delete(arg_project, arg_taskqueue, arg_task).then(unittest.expectAsync
((_) {})); |
380 }); | 415 }); |
381 | 416 |
382 unittest.test("method--get", () { | 417 unittest.test("method--get", () { |
383 | 418 |
384 var mock = new common_test.HttpServerMock(); | 419 var mock = new HttpServerMock(); |
385 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; | 420 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; |
386 var arg_project = "foo"; | 421 var arg_project = "foo"; |
387 var arg_taskqueue = "foo"; | 422 var arg_taskqueue = "foo"; |
388 var arg_task = "foo"; | 423 var arg_task = "foo"; |
389 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 424 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
390 var path = (req.url).path; | 425 var path = (req.url).path; |
391 var pathOffset = 0; | 426 var pathOffset = 0; |
392 var index; | 427 var index; |
393 var subPart; | 428 var subPart; |
394 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 429 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
(...skipping 14 matching lines...) Expand all Loading... |
409 var keyvalue = part.split("="); | 444 var keyvalue = part.split("="); |
410 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 445 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
411 } | 446 } |
412 } | 447 } |
413 | 448 |
414 | 449 |
415 var h = { | 450 var h = { |
416 "content-type" : "application/json; charset=utf-8", | 451 "content-type" : "application/json; charset=utf-8", |
417 }; | 452 }; |
418 var resp = convert.JSON.encode(buildTask()); | 453 var resp = convert.JSON.encode(buildTask()); |
419 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 454 return new async.Future.value(stringResponse(200, h, resp)); |
420 }), true); | 455 }), true); |
421 res.get(arg_project, arg_taskqueue, arg_task).then(unittest.expectAsync(((
api.Task response) { | 456 res.get(arg_project, arg_taskqueue, arg_task).then(unittest.expectAsync(((
api.Task response) { |
422 checkTask(response); | 457 checkTask(response); |
423 }))); | 458 }))); |
424 }); | 459 }); |
425 | 460 |
426 unittest.test("method--insert", () { | 461 unittest.test("method--insert", () { |
427 | 462 |
428 var mock = new common_test.HttpServerMock(); | 463 var mock = new HttpServerMock(); |
429 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; | 464 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; |
430 var arg_request = buildTask(); | 465 var arg_request = buildTask(); |
431 var arg_project = "foo"; | 466 var arg_project = "foo"; |
432 var arg_taskqueue = "foo"; | 467 var arg_taskqueue = "foo"; |
433 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 468 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
434 var obj = new api.Task.fromJson(json); | 469 var obj = new api.Task.fromJson(json); |
435 checkTask(obj); | 470 checkTask(obj); |
436 | 471 |
437 var path = (req.url).path; | 472 var path = (req.url).path; |
438 var pathOffset = 0; | 473 var pathOffset = 0; |
(...skipping 17 matching lines...) Expand all Loading... |
456 var keyvalue = part.split("="); | 491 var keyvalue = part.split("="); |
457 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 492 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
458 } | 493 } |
459 } | 494 } |
460 | 495 |
461 | 496 |
462 var h = { | 497 var h = { |
463 "content-type" : "application/json; charset=utf-8", | 498 "content-type" : "application/json; charset=utf-8", |
464 }; | 499 }; |
465 var resp = convert.JSON.encode(buildTask()); | 500 var resp = convert.JSON.encode(buildTask()); |
466 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 501 return new async.Future.value(stringResponse(200, h, resp)); |
467 }), true); | 502 }), true); |
468 res.insert(arg_request, arg_project, arg_taskqueue).then(unittest.expectAs
ync(((api.Task response) { | 503 res.insert(arg_request, arg_project, arg_taskqueue).then(unittest.expectAs
ync(((api.Task response) { |
469 checkTask(response); | 504 checkTask(response); |
470 }))); | 505 }))); |
471 }); | 506 }); |
472 | 507 |
473 unittest.test("method--lease", () { | 508 unittest.test("method--lease", () { |
474 | 509 |
475 var mock = new common_test.HttpServerMock(); | 510 var mock = new HttpServerMock(); |
476 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; | 511 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; |
477 var arg_project = "foo"; | 512 var arg_project = "foo"; |
478 var arg_taskqueue = "foo"; | 513 var arg_taskqueue = "foo"; |
479 var arg_numTasks = 42; | 514 var arg_numTasks = 42; |
480 var arg_leaseSecs = 42; | 515 var arg_leaseSecs = 42; |
481 var arg_groupByTag = true; | 516 var arg_groupByTag = true; |
482 var arg_tag = "foo"; | 517 var arg_tag = "foo"; |
483 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 518 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
484 var path = (req.url).path; | 519 var path = (req.url).path; |
485 var pathOffset = 0; | 520 var pathOffset = 0; |
(...skipping 21 matching lines...) Expand all Loading... |
507 unittest.expect(core.int.parse(queryMap["numTasks"].first), unittest.equ
als(arg_numTasks)); | 542 unittest.expect(core.int.parse(queryMap["numTasks"].first), unittest.equ
als(arg_numTasks)); |
508 unittest.expect(core.int.parse(queryMap["leaseSecs"].first), unittest.eq
uals(arg_leaseSecs)); | 543 unittest.expect(core.int.parse(queryMap["leaseSecs"].first), unittest.eq
uals(arg_leaseSecs)); |
509 unittest.expect(queryMap["groupByTag"].first, unittest.equals("$arg_grou
pByTag")); | 544 unittest.expect(queryMap["groupByTag"].first, unittest.equals("$arg_grou
pByTag")); |
510 unittest.expect(queryMap["tag"].first, unittest.equals(arg_tag)); | 545 unittest.expect(queryMap["tag"].first, unittest.equals(arg_tag)); |
511 | 546 |
512 | 547 |
513 var h = { | 548 var h = { |
514 "content-type" : "application/json; charset=utf-8", | 549 "content-type" : "application/json; charset=utf-8", |
515 }; | 550 }; |
516 var resp = convert.JSON.encode(buildTasks()); | 551 var resp = convert.JSON.encode(buildTasks()); |
517 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 552 return new async.Future.value(stringResponse(200, h, resp)); |
518 }), true); | 553 }), true); |
519 res.lease(arg_project, arg_taskqueue, arg_numTasks, arg_leaseSecs, groupBy
Tag: arg_groupByTag, tag: arg_tag).then(unittest.expectAsync(((api.Tasks respons
e) { | 554 res.lease(arg_project, arg_taskqueue, arg_numTasks, arg_leaseSecs, groupBy
Tag: arg_groupByTag, tag: arg_tag).then(unittest.expectAsync(((api.Tasks respons
e) { |
520 checkTasks(response); | 555 checkTasks(response); |
521 }))); | 556 }))); |
522 }); | 557 }); |
523 | 558 |
524 unittest.test("method--list", () { | 559 unittest.test("method--list", () { |
525 | 560 |
526 var mock = new common_test.HttpServerMock(); | 561 var mock = new HttpServerMock(); |
527 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; | 562 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; |
528 var arg_project = "foo"; | 563 var arg_project = "foo"; |
529 var arg_taskqueue = "foo"; | 564 var arg_taskqueue = "foo"; |
530 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 565 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
531 var path = (req.url).path; | 566 var path = (req.url).path; |
532 var pathOffset = 0; | 567 var pathOffset = 0; |
533 var index; | 568 var index; |
534 var subPart; | 569 var subPart; |
535 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 570 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
536 pathOffset += 1; | 571 pathOffset += 1; |
(...skipping 13 matching lines...) Expand all Loading... |
550 var keyvalue = part.split("="); | 585 var keyvalue = part.split("="); |
551 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 586 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
552 } | 587 } |
553 } | 588 } |
554 | 589 |
555 | 590 |
556 var h = { | 591 var h = { |
557 "content-type" : "application/json; charset=utf-8", | 592 "content-type" : "application/json; charset=utf-8", |
558 }; | 593 }; |
559 var resp = convert.JSON.encode(buildTasks2()); | 594 var resp = convert.JSON.encode(buildTasks2()); |
560 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 595 return new async.Future.value(stringResponse(200, h, resp)); |
561 }), true); | 596 }), true); |
562 res.list(arg_project, arg_taskqueue).then(unittest.expectAsync(((api.Tasks
2 response) { | 597 res.list(arg_project, arg_taskqueue).then(unittest.expectAsync(((api.Tasks
2 response) { |
563 checkTasks2(response); | 598 checkTasks2(response); |
564 }))); | 599 }))); |
565 }); | 600 }); |
566 | 601 |
567 unittest.test("method--patch", () { | 602 unittest.test("method--patch", () { |
568 | 603 |
569 var mock = new common_test.HttpServerMock(); | 604 var mock = new HttpServerMock(); |
570 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; | 605 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; |
571 var arg_request = buildTask(); | 606 var arg_request = buildTask(); |
572 var arg_project = "foo"; | 607 var arg_project = "foo"; |
573 var arg_taskqueue = "foo"; | 608 var arg_taskqueue = "foo"; |
574 var arg_task = "foo"; | 609 var arg_task = "foo"; |
575 var arg_newLeaseSeconds = 42; | 610 var arg_newLeaseSeconds = 42; |
576 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 611 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
577 var obj = new api.Task.fromJson(json); | 612 var obj = new api.Task.fromJson(json); |
578 checkTask(obj); | 613 checkTask(obj); |
579 | 614 |
(...skipping 20 matching lines...) Expand all Loading... |
600 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 635 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
601 } | 636 } |
602 } | 637 } |
603 unittest.expect(core.int.parse(queryMap["newLeaseSeconds"].first), unitt
est.equals(arg_newLeaseSeconds)); | 638 unittest.expect(core.int.parse(queryMap["newLeaseSeconds"].first), unitt
est.equals(arg_newLeaseSeconds)); |
604 | 639 |
605 | 640 |
606 var h = { | 641 var h = { |
607 "content-type" : "application/json; charset=utf-8", | 642 "content-type" : "application/json; charset=utf-8", |
608 }; | 643 }; |
609 var resp = convert.JSON.encode(buildTask()); | 644 var resp = convert.JSON.encode(buildTask()); |
610 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 645 return new async.Future.value(stringResponse(200, h, resp)); |
611 }), true); | 646 }), true); |
612 res.patch(arg_request, arg_project, arg_taskqueue, arg_task, arg_newLeaseS
econds).then(unittest.expectAsync(((api.Task response) { | 647 res.patch(arg_request, arg_project, arg_taskqueue, arg_task, arg_newLeaseS
econds).then(unittest.expectAsync(((api.Task response) { |
613 checkTask(response); | 648 checkTask(response); |
614 }))); | 649 }))); |
615 }); | 650 }); |
616 | 651 |
617 unittest.test("method--update", () { | 652 unittest.test("method--update", () { |
618 | 653 |
619 var mock = new common_test.HttpServerMock(); | 654 var mock = new HttpServerMock(); |
620 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; | 655 api.TasksResourceApi res = new api.TaskqueueApi(mock).tasks; |
621 var arg_request = buildTask(); | 656 var arg_request = buildTask(); |
622 var arg_project = "foo"; | 657 var arg_project = "foo"; |
623 var arg_taskqueue = "foo"; | 658 var arg_taskqueue = "foo"; |
624 var arg_task = "foo"; | 659 var arg_task = "foo"; |
625 var arg_newLeaseSeconds = 42; | 660 var arg_newLeaseSeconds = 42; |
626 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | 661 mock.register(unittest.expectAsync((http.BaseRequest req, json) { |
627 var obj = new api.Task.fromJson(json); | 662 var obj = new api.Task.fromJson(json); |
628 checkTask(obj); | 663 checkTask(obj); |
629 | 664 |
(...skipping 20 matching lines...) Expand all Loading... |
650 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 685 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
651 } | 686 } |
652 } | 687 } |
653 unittest.expect(core.int.parse(queryMap["newLeaseSeconds"].first), unitt
est.equals(arg_newLeaseSeconds)); | 688 unittest.expect(core.int.parse(queryMap["newLeaseSeconds"].first), unitt
est.equals(arg_newLeaseSeconds)); |
654 | 689 |
655 | 690 |
656 var h = { | 691 var h = { |
657 "content-type" : "application/json; charset=utf-8", | 692 "content-type" : "application/json; charset=utf-8", |
658 }; | 693 }; |
659 var resp = convert.JSON.encode(buildTask()); | 694 var resp = convert.JSON.encode(buildTask()); |
660 return new async.Future.value(common_test.stringResponse(200, h, resp)); | 695 return new async.Future.value(stringResponse(200, h, resp)); |
661 }), true); | 696 }), true); |
662 res.update(arg_request, arg_project, arg_taskqueue, arg_task, arg_newLease
Seconds).then(unittest.expectAsync(((api.Task response) { | 697 res.update(arg_request, arg_project, arg_taskqueue, arg_task, arg_newLease
Seconds).then(unittest.expectAsync(((api.Task response) { |
663 checkTask(response); | 698 checkTask(response); |
664 }))); | 699 }))); |
665 }); | 700 }); |
666 | 701 |
667 }); | 702 }); |
668 | 703 |
669 | 704 |
670 } | 705 } |
671 | 706 |
OLD | NEW |