Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: generated/googleapis/test/cloudfunctions/v1_test.dart

Issue 2987103002: Api-Roll 52: 2017-07-31 (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 library googleapis.cloudfunctions.v1.test; 1 library googleapis.cloudfunctions.v1.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:test/test.dart' as unittest; 10 import 'package:test/test.dart' as unittest;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 } 44 }
45 } 45 }
46 } 46 }
47 47
48 http.StreamedResponse stringResponse( 48 http.StreamedResponse stringResponse(
49 core.int status, core.Map<core.String, core.String> headers, core.String bod y) { 49 core.int status, core.Map<core.String, core.String> headers, core.String bod y) {
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); 50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]);
51 return new http.StreamedResponse(stream, status, headers: headers); 51 return new http.StreamedResponse(stream, status, headers: headers);
52 } 52 }
53 53
54 buildUnnamed178() { 54 buildUnnamed141() {
55 var o = new core.List<api.Location>();
56 o.add(buildLocation());
57 o.add(buildLocation());
58 return o;
59 }
60
61 checkUnnamed141(core.List<api.Location> o) {
62 unittest.expect(o, unittest.hasLength(2));
63 checkLocation(o[0]);
64 checkLocation(o[1]);
65 }
66
67 core.int buildCounterListLocationsResponse = 0;
68 buildListLocationsResponse() {
69 var o = new api.ListLocationsResponse();
70 buildCounterListLocationsResponse++;
71 if (buildCounterListLocationsResponse < 3) {
72 o.locations = buildUnnamed141();
73 o.nextPageToken = "foo";
74 }
75 buildCounterListLocationsResponse--;
76 return o;
77 }
78
79 checkListLocationsResponse(api.ListLocationsResponse o) {
80 buildCounterListLocationsResponse++;
81 if (buildCounterListLocationsResponse < 3) {
82 checkUnnamed141(o.locations);
83 unittest.expect(o.nextPageToken, unittest.equals('foo'));
84 }
85 buildCounterListLocationsResponse--;
86 }
87
88 buildUnnamed142() {
89 var o = new core.List<api.Operation>();
90 o.add(buildOperation());
91 o.add(buildOperation());
92 return o;
93 }
94
95 checkUnnamed142(core.List<api.Operation> o) {
96 unittest.expect(o, unittest.hasLength(2));
97 checkOperation(o[0]);
98 checkOperation(o[1]);
99 }
100
101 core.int buildCounterListOperationsResponse = 0;
102 buildListOperationsResponse() {
103 var o = new api.ListOperationsResponse();
104 buildCounterListOperationsResponse++;
105 if (buildCounterListOperationsResponse < 3) {
106 o.nextPageToken = "foo";
107 o.operations = buildUnnamed142();
108 }
109 buildCounterListOperationsResponse--;
110 return o;
111 }
112
113 checkListOperationsResponse(api.ListOperationsResponse o) {
114 buildCounterListOperationsResponse++;
115 if (buildCounterListOperationsResponse < 3) {
116 unittest.expect(o.nextPageToken, unittest.equals('foo'));
117 checkUnnamed142(o.operations);
118 }
119 buildCounterListOperationsResponse--;
120 }
121
122 buildUnnamed143() {
123 var o = new core.Map<core.String, core.String>();
124 o["x"] = "foo";
125 o["y"] = "foo";
126 return o;
127 }
128
129 checkUnnamed143(core.Map<core.String, core.String> o) {
130 unittest.expect(o, unittest.hasLength(2));
131 unittest.expect(o["x"], unittest.equals('foo'));
132 unittest.expect(o["y"], unittest.equals('foo'));
133 }
134
135 buildUnnamed144() {
55 var o = new core.Map<core.String, core.Object>(); 136 var o = new core.Map<core.String, core.Object>();
56 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 137 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
57 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'}; 138 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
58 return o; 139 return o;
59 } 140 }
60 141
61 checkUnnamed178(core.Map<core.String, core.Object> o) { 142 checkUnnamed144(core.Map<core.String, core.Object> o) {
62 unittest.expect(o, unittest.hasLength(2)); 143 unittest.expect(o, unittest.hasLength(2));
63 var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLengt h(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], unittest.equals('foo')); 144 var casted1 = (o["x"]) as core.Map; unittest.expect(casted1, unittest.hasLengt h(3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], unittest.equals('foo'));
64 var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLengt h(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], unittest.equals('foo')); 145 var casted2 = (o["y"]) as core.Map; unittest.expect(casted2, unittest.hasLengt h(3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], unittest.equals('foo'));
65 } 146 }
66 147
148 core.int buildCounterLocation = 0;
149 buildLocation() {
150 var o = new api.Location();
151 buildCounterLocation++;
152 if (buildCounterLocation < 3) {
153 o.labels = buildUnnamed143();
154 o.locationId = "foo";
155 o.metadata = buildUnnamed144();
156 o.name = "foo";
157 }
158 buildCounterLocation--;
159 return o;
160 }
161
162 checkLocation(api.Location o) {
163 buildCounterLocation++;
164 if (buildCounterLocation < 3) {
165 checkUnnamed143(o.labels);
166 unittest.expect(o.locationId, unittest.equals('foo'));
167 checkUnnamed144(o.metadata);
168 unittest.expect(o.name, unittest.equals('foo'));
169 }
170 buildCounterLocation--;
171 }
172
173 buildUnnamed145() {
174 var o = new core.Map<core.String, core.Object>();
175 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
176 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
177 return o;
178 }
179
180 checkUnnamed145(core.Map<core.String, core.Object> o) {
181 unittest.expect(o, unittest.hasLength(2));
182 var casted3 = (o["x"]) as core.Map; unittest.expect(casted3, unittest.hasLengt h(3)); unittest.expect(casted3["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted3["bool"], unittest.equals(true)); unittest.expect(casted3["string"], unittest.equals('foo'));
183 var casted4 = (o["y"]) as core.Map; unittest.expect(casted4, unittest.hasLengt h(3)); unittest.expect(casted4["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted4["bool"], unittest.equals(true)); unittest.expect(casted4["string"], unittest.equals('foo'));
184 }
185
186 buildUnnamed146() {
187 var o = new core.Map<core.String, core.Object>();
188 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
189 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
190 return o;
191 }
192
193 checkUnnamed146(core.Map<core.String, core.Object> o) {
194 unittest.expect(o, unittest.hasLength(2));
195 var casted5 = (o["x"]) as core.Map; unittest.expect(casted5, unittest.hasLengt h(3)); unittest.expect(casted5["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted5["bool"], unittest.equals(true)); unittest.expect(casted5["string"], unittest.equals('foo'));
196 var casted6 = (o["y"]) as core.Map; unittest.expect(casted6, unittest.hasLengt h(3)); unittest.expect(casted6["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted6["bool"], unittest.equals(true)); unittest.expect(casted6["string"], unittest.equals('foo'));
197 }
198
199 core.int buildCounterOperation = 0;
200 buildOperation() {
201 var o = new api.Operation();
202 buildCounterOperation++;
203 if (buildCounterOperation < 3) {
204 o.done = true;
205 o.error = buildStatus();
206 o.metadata = buildUnnamed145();
207 o.name = "foo";
208 o.response = buildUnnamed146();
209 }
210 buildCounterOperation--;
211 return o;
212 }
213
214 checkOperation(api.Operation o) {
215 buildCounterOperation++;
216 if (buildCounterOperation < 3) {
217 unittest.expect(o.done, unittest.isTrue);
218 checkStatus(o.error);
219 checkUnnamed145(o.metadata);
220 unittest.expect(o.name, unittest.equals('foo'));
221 checkUnnamed146(o.response);
222 }
223 buildCounterOperation--;
224 }
225
226 buildUnnamed147() {
227 var o = new core.Map<core.String, core.Object>();
228 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
229 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
230 return o;
231 }
232
233 checkUnnamed147(core.Map<core.String, core.Object> o) {
234 unittest.expect(o, unittest.hasLength(2));
235 var casted7 = (o["x"]) as core.Map; unittest.expect(casted7, unittest.hasLengt h(3)); unittest.expect(casted7["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted7["bool"], unittest.equals(true)); unittest.expect(casted7["string"], unittest.equals('foo'));
236 var casted8 = (o["y"]) as core.Map; unittest.expect(casted8, unittest.hasLengt h(3)); unittest.expect(casted8["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted8["bool"], unittest.equals(true)); unittest.expect(casted8["string"], unittest.equals('foo'));
237 }
238
67 core.int buildCounterOperationMetadataV1Beta2 = 0; 239 core.int buildCounterOperationMetadataV1Beta2 = 0;
68 buildOperationMetadataV1Beta2() { 240 buildOperationMetadataV1Beta2() {
69 var o = new api.OperationMetadataV1Beta2(); 241 var o = new api.OperationMetadataV1Beta2();
70 buildCounterOperationMetadataV1Beta2++; 242 buildCounterOperationMetadataV1Beta2++;
71 if (buildCounterOperationMetadataV1Beta2 < 3) { 243 if (buildCounterOperationMetadataV1Beta2 < 3) {
72 o.request = buildUnnamed178(); 244 o.request = buildUnnamed147();
73 o.target = "foo"; 245 o.target = "foo";
74 o.type = "foo"; 246 o.type = "foo";
75 } 247 }
76 buildCounterOperationMetadataV1Beta2--; 248 buildCounterOperationMetadataV1Beta2--;
77 return o; 249 return o;
78 } 250 }
79 251
80 checkOperationMetadataV1Beta2(api.OperationMetadataV1Beta2 o) { 252 checkOperationMetadataV1Beta2(api.OperationMetadataV1Beta2 o) {
81 buildCounterOperationMetadataV1Beta2++; 253 buildCounterOperationMetadataV1Beta2++;
82 if (buildCounterOperationMetadataV1Beta2 < 3) { 254 if (buildCounterOperationMetadataV1Beta2 < 3) {
83 checkUnnamed178(o.request); 255 checkUnnamed147(o.request);
84 unittest.expect(o.target, unittest.equals('foo')); 256 unittest.expect(o.target, unittest.equals('foo'));
85 unittest.expect(o.type, unittest.equals('foo')); 257 unittest.expect(o.type, unittest.equals('foo'));
86 } 258 }
87 buildCounterOperationMetadataV1Beta2--; 259 buildCounterOperationMetadataV1Beta2--;
88 } 260 }
89 261
262 buildUnnamed148() {
263 var o = new core.Map<core.String, core.Object>();
264 o["x"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
265 o["y"] = {'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'};
266 return o;
267 }
268
269 checkUnnamed148(core.Map<core.String, core.Object> o) {
270 unittest.expect(o, unittest.hasLength(2));
271 var casted9 = (o["x"]) as core.Map; unittest.expect(casted9, unittest.hasLengt h(3)); unittest.expect(casted9["list"], unittest.equals([1, 2, 3])); unittest.ex pect(casted9["bool"], unittest.equals(true)); unittest.expect(casted9["string"], unittest.equals('foo'));
272 var casted10 = (o["y"]) as core.Map; unittest.expect(casted10, unittest.hasLen gth(3)); unittest.expect(casted10["list"], unittest.equals([1, 2, 3])); unittest .expect(casted10["bool"], unittest.equals(true)); unittest.expect(casted10["stri ng"], unittest.equals('foo'));
273 }
274
275 buildUnnamed149() {
276 var o = new core.List<core.Map<core.String, core.Object>>();
277 o.add(buildUnnamed148());
278 o.add(buildUnnamed148());
279 return o;
280 }
281
282 checkUnnamed149(core.List<core.Map<core.String, core.Object>> o) {
283 unittest.expect(o, unittest.hasLength(2));
284 checkUnnamed148(o[0]);
285 checkUnnamed148(o[1]);
286 }
287
288 core.int buildCounterStatus = 0;
289 buildStatus() {
290 var o = new api.Status();
291 buildCounterStatus++;
292 if (buildCounterStatus < 3) {
293 o.code = 42;
294 o.details = buildUnnamed149();
295 o.message = "foo";
296 }
297 buildCounterStatus--;
298 return o;
299 }
300
301 checkStatus(api.Status o) {
302 buildCounterStatus++;
303 if (buildCounterStatus < 3) {
304 unittest.expect(o.code, unittest.equals(42));
305 checkUnnamed149(o.details);
306 unittest.expect(o.message, unittest.equals('foo'));
307 }
308 buildCounterStatus--;
309 }
310
90 311
91 main() { 312 main() {
313 unittest.group("obj-schema-ListLocationsResponse", () {
314 unittest.test("to-json--from-json", () {
315 var o = buildListLocationsResponse();
316 var od = new api.ListLocationsResponse.fromJson(o.toJson());
317 checkListLocationsResponse(od);
318 });
319 });
320
321
322 unittest.group("obj-schema-ListOperationsResponse", () {
323 unittest.test("to-json--from-json", () {
324 var o = buildListOperationsResponse();
325 var od = new api.ListOperationsResponse.fromJson(o.toJson());
326 checkListOperationsResponse(od);
327 });
328 });
329
330
331 unittest.group("obj-schema-Location", () {
332 unittest.test("to-json--from-json", () {
333 var o = buildLocation();
334 var od = new api.Location.fromJson(o.toJson());
335 checkLocation(od);
336 });
337 });
338
339
340 unittest.group("obj-schema-Operation", () {
341 unittest.test("to-json--from-json", () {
342 var o = buildOperation();
343 var od = new api.Operation.fromJson(o.toJson());
344 checkOperation(od);
345 });
346 });
347
348
92 unittest.group("obj-schema-OperationMetadataV1Beta2", () { 349 unittest.group("obj-schema-OperationMetadataV1Beta2", () {
93 unittest.test("to-json--from-json", () { 350 unittest.test("to-json--from-json", () {
94 var o = buildOperationMetadataV1Beta2(); 351 var o = buildOperationMetadataV1Beta2();
95 var od = new api.OperationMetadataV1Beta2.fromJson(o.toJson()); 352 var od = new api.OperationMetadataV1Beta2.fromJson(o.toJson());
96 checkOperationMetadataV1Beta2(od); 353 checkOperationMetadataV1Beta2(od);
97 }); 354 });
98 }); 355 });
99 356
100 357
358 unittest.group("obj-schema-Status", () {
359 unittest.test("to-json--from-json", () {
360 var o = buildStatus();
361 var od = new api.Status.fromJson(o.toJson());
362 checkStatus(od);
363 });
364 });
365
366
367 unittest.group("resource-OperationsResourceApi", () {
368 unittest.test("method--get", () {
369
370 var mock = new HttpServerMock();
371 api.OperationsResourceApi res = new api.CloudfunctionsApi(mock).operations ;
372 var arg_name = "foo";
373 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
374 var path = (req.url).path;
375 var pathOffset = 0;
376 var index;
377 var subPart;
378 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
379 pathOffset += 1;
380 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v1/"));
381 pathOffset += 3;
382 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
383
384 var query = (req.url).query;
385 var queryOffset = 0;
386 var queryMap = {};
387 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
388 parseBool(n) {
389 if (n == "true") return true;
390 if (n == "false") return false;
391 if (n == null) return null;
392 throw new core.ArgumentError("Invalid boolean: $n");
393 }
394 if (query.length > 0) {
395 for (var part in query.split("&")) {
396 var keyvalue = part.split("=");
397 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
398 }
399 }
400
401
402 var h = {
403 "content-type" : "application/json; charset=utf-8",
404 };
405 var resp = convert.JSON.encode(buildOperation());
406 return new async.Future.value(stringResponse(200, h, resp));
407 }), true);
408 res.get(arg_name).then(unittest.expectAsync1(((api.Operation response) {
409 checkOperation(response);
410 })));
411 });
412
413 unittest.test("method--list", () {
414
415 var mock = new HttpServerMock();
416 api.OperationsResourceApi res = new api.CloudfunctionsApi(mock).operations ;
417 var arg_pageToken = "foo";
418 var arg_name = "foo";
419 var arg_pageSize = 42;
420 var arg_filter = "foo";
421 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
422 var path = (req.url).path;
423 var pathOffset = 0;
424 var index;
425 var subPart;
426 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
427 pathOffset += 1;
428 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq uals("v1/operations"));
429 pathOffset += 13;
430
431 var query = (req.url).query;
432 var queryOffset = 0;
433 var queryMap = {};
434 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
435 parseBool(n) {
436 if (n == "true") return true;
437 if (n == "false") return false;
438 if (n == null) return null;
439 throw new core.ArgumentError("Invalid boolean: $n");
440 }
441 if (query.length > 0) {
442 for (var part in query.split("&")) {
443 var keyvalue = part.split("=");
444 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
445 }
446 }
447 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
448 unittest.expect(queryMap["name"].first, unittest.equals(arg_name));
449 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ als(arg_pageSize));
450 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
451
452
453 var h = {
454 "content-type" : "application/json; charset=utf-8",
455 };
456 var resp = convert.JSON.encode(buildListOperationsResponse());
457 return new async.Future.value(stringResponse(200, h, resp));
458 }), true);
459 res.list(pageToken: arg_pageToken, name: arg_name, pageSize: arg_pageSize, filter: arg_filter).then(unittest.expectAsync1(((api.ListOperationsResponse res ponse) {
460 checkListOperationsResponse(response);
461 })));
462 });
463
464 });
465
466
467 unittest.group("resource-ProjectsLocationsResourceApi", () {
468 unittest.test("method--list", () {
469
470 var mock = new HttpServerMock();
471 api.ProjectsLocationsResourceApi res = new api.CloudfunctionsApi(mock).pro jects.locations;
472 var arg_name = "foo";
473 var arg_filter = "foo";
474 var arg_pageToken = "foo";
475 var arg_pageSize = 42;
476 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
477 var path = (req.url).path;
478 var pathOffset = 0;
479 var index;
480 var subPart;
481 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/"));
482 pathOffset += 1;
483 unittest.expect(path.substring(pathOffset, pathOffset + 3), unittest.equ als("v1/"));
484 pathOffset += 3;
485 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
486
487 var query = (req.url).query;
488 var queryOffset = 0;
489 var queryMap = {};
490 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
491 parseBool(n) {
492 if (n == "true") return true;
493 if (n == "false") return false;
494 if (n == null) return null;
495 throw new core.ArgumentError("Invalid boolean: $n");
496 }
497 if (query.length > 0) {
498 for (var part in query.split("&")) {
499 var keyvalue = part.split("=");
500 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
501 }
502 }
503 unittest.expect(queryMap["filter"].first, unittest.equals(arg_filter));
504 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok en));
505 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ als(arg_pageSize));
506
507
508 var h = {
509 "content-type" : "application/json; charset=utf-8",
510 };
511 var resp = convert.JSON.encode(buildListLocationsResponse());
512 return new async.Future.value(stringResponse(200, h, resp));
513 }), true);
514 res.list(arg_name, filter: arg_filter, pageToken: arg_pageToken, pageSize: arg_pageSize).then(unittest.expectAsync1(((api.ListLocationsResponse response) {
515 checkListLocationsResponse(response);
516 })));
517 });
518
519 });
520
521
101 } 522 }
102 523
OLDNEW
« no previous file with comments | « generated/googleapis/test/clouddebugger/v2_test.dart ('k') | generated/googleapis/test/cloudkms/v1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698