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

Side by Side Diff: generated/googleapis/test/youtubeanalytics/v1.dart

Issue 559053002: Generate 0.1.0 version of googleapis/googleapis_beta (Closed) Base URL: git@github.com:dart-lang/googleapis.git@master
Patch Set: Created 6 years, 3 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
(Empty)
1 library googleapis.youtubeAnalytics.v1.test;
2
3 import "dart:core" as core;
4 import "dart:collection" as collection;
5 import "dart:async" as async;
6 import "dart:convert" as convert;
7
8 import 'package:http/http.dart' as http;
9 import 'package:http/testing.dart' as http_testing;
10 import 'package:unittest/unittest.dart' as unittest;
11 import 'package:googleapis/common/common.dart' as common;
12 import 'package:googleapis/src/common_internal.dart' as common_internal;
13 import '../common/common_internal_test.dart' as common_test;
14
15 import 'package:googleapis/youtubeanalytics/v1.dart' as api;
16
17
18
19 buildUnnamed204() {
20 var o = new core.List<api.BatchReportDefinitionTemplate>();
21 o.add(buildBatchReportDefinitionTemplate());
22 o.add(buildBatchReportDefinitionTemplate());
23 return o;
24 }
25
26 checkUnnamed204(core.List<api.BatchReportDefinitionTemplate> o) {
27 unittest.expect(o, unittest.hasLength(2));
28 checkBatchReportDefinitionTemplate(o[0]);
29 checkBatchReportDefinitionTemplate(o[1]);
30 }
31
32 core.int buildCounterBatchReportDefinitionList = 0;
33 buildBatchReportDefinitionList() {
34 var o = new api.BatchReportDefinitionList();
35 buildCounterBatchReportDefinitionList++;
36 if (buildCounterBatchReportDefinitionList < 3) {
37 o.items = buildUnnamed204();
38 o.kind = "foo";
39 }
40 buildCounterBatchReportDefinitionList--;
41 return o;
42 }
43
44 checkBatchReportDefinitionList(api.BatchReportDefinitionList o) {
45 buildCounterBatchReportDefinitionList++;
46 if (buildCounterBatchReportDefinitionList < 3) {
47 checkUnnamed204(o.items);
48 unittest.expect(o.kind, unittest.equals('foo'));
49 }
50 buildCounterBatchReportDefinitionList--;
51 }
52
53 core.int buildCounterBatchReportDefinitionTemplateDefaultOutput = 0;
54 buildBatchReportDefinitionTemplateDefaultOutput() {
55 var o = new api.BatchReportDefinitionTemplateDefaultOutput();
56 buildCounterBatchReportDefinitionTemplateDefaultOutput++;
57 if (buildCounterBatchReportDefinitionTemplateDefaultOutput < 3) {
58 o.format = "foo";
59 o.type = "foo";
60 }
61 buildCounterBatchReportDefinitionTemplateDefaultOutput--;
62 return o;
63 }
64
65 checkBatchReportDefinitionTemplateDefaultOutput(api.BatchReportDefinitionTemplat eDefaultOutput o) {
66 buildCounterBatchReportDefinitionTemplateDefaultOutput++;
67 if (buildCounterBatchReportDefinitionTemplateDefaultOutput < 3) {
68 unittest.expect(o.format, unittest.equals('foo'));
69 unittest.expect(o.type, unittest.equals('foo'));
70 }
71 buildCounterBatchReportDefinitionTemplateDefaultOutput--;
72 }
73
74 buildUnnamed205() {
75 var o = new core.List<api.BatchReportDefinitionTemplateDefaultOutput>();
76 o.add(buildBatchReportDefinitionTemplateDefaultOutput());
77 o.add(buildBatchReportDefinitionTemplateDefaultOutput());
78 return o;
79 }
80
81 checkUnnamed205(core.List<api.BatchReportDefinitionTemplateDefaultOutput> o) {
82 unittest.expect(o, unittest.hasLength(2));
83 checkBatchReportDefinitionTemplateDefaultOutput(o[0]);
84 checkBatchReportDefinitionTemplateDefaultOutput(o[1]);
85 }
86
87 core.int buildCounterBatchReportDefinitionTemplate = 0;
88 buildBatchReportDefinitionTemplate() {
89 var o = new api.BatchReportDefinitionTemplate();
90 buildCounterBatchReportDefinitionTemplate++;
91 if (buildCounterBatchReportDefinitionTemplate < 3) {
92 o.defaultOutput = buildUnnamed205();
93 o.id = "foo";
94 o.name = "foo";
95 o.status = "foo";
96 o.type = "foo";
97 }
98 buildCounterBatchReportDefinitionTemplate--;
99 return o;
100 }
101
102 checkBatchReportDefinitionTemplate(api.BatchReportDefinitionTemplate o) {
103 buildCounterBatchReportDefinitionTemplate++;
104 if (buildCounterBatchReportDefinitionTemplate < 3) {
105 checkUnnamed205(o.defaultOutput);
106 unittest.expect(o.id, unittest.equals('foo'));
107 unittest.expect(o.name, unittest.equals('foo'));
108 unittest.expect(o.status, unittest.equals('foo'));
109 unittest.expect(o.type, unittest.equals('foo'));
110 }
111 buildCounterBatchReportDefinitionTemplate--;
112 }
113
114 buildUnnamed206() {
115 var o = new core.List<api.BatchReportTemplate>();
116 o.add(buildBatchReportTemplate());
117 o.add(buildBatchReportTemplate());
118 return o;
119 }
120
121 checkUnnamed206(core.List<api.BatchReportTemplate> o) {
122 unittest.expect(o, unittest.hasLength(2));
123 checkBatchReportTemplate(o[0]);
124 checkBatchReportTemplate(o[1]);
125 }
126
127 core.int buildCounterBatchReportList = 0;
128 buildBatchReportList() {
129 var o = new api.BatchReportList();
130 buildCounterBatchReportList++;
131 if (buildCounterBatchReportList < 3) {
132 o.items = buildUnnamed206();
133 o.kind = "foo";
134 }
135 buildCounterBatchReportList--;
136 return o;
137 }
138
139 checkBatchReportList(api.BatchReportList o) {
140 buildCounterBatchReportList++;
141 if (buildCounterBatchReportList < 3) {
142 checkUnnamed206(o.items);
143 unittest.expect(o.kind, unittest.equals('foo'));
144 }
145 buildCounterBatchReportList--;
146 }
147
148 core.int buildCounterBatchReportTemplateOutputs = 0;
149 buildBatchReportTemplateOutputs() {
150 var o = new api.BatchReportTemplateOutputs();
151 buildCounterBatchReportTemplateOutputs++;
152 if (buildCounterBatchReportTemplateOutputs < 3) {
153 o.downloadUrl = "foo";
154 o.format = "foo";
155 o.type = "foo";
156 }
157 buildCounterBatchReportTemplateOutputs--;
158 return o;
159 }
160
161 checkBatchReportTemplateOutputs(api.BatchReportTemplateOutputs o) {
162 buildCounterBatchReportTemplateOutputs++;
163 if (buildCounterBatchReportTemplateOutputs < 3) {
164 unittest.expect(o.downloadUrl, unittest.equals('foo'));
165 unittest.expect(o.format, unittest.equals('foo'));
166 unittest.expect(o.type, unittest.equals('foo'));
167 }
168 buildCounterBatchReportTemplateOutputs--;
169 }
170
171 buildUnnamed207() {
172 var o = new core.List<api.BatchReportTemplateOutputs>();
173 o.add(buildBatchReportTemplateOutputs());
174 o.add(buildBatchReportTemplateOutputs());
175 return o;
176 }
177
178 checkUnnamed207(core.List<api.BatchReportTemplateOutputs> o) {
179 unittest.expect(o, unittest.hasLength(2));
180 checkBatchReportTemplateOutputs(o[0]);
181 checkBatchReportTemplateOutputs(o[1]);
182 }
183
184 core.int buildCounterBatchReportTemplateTimeSpan = 0;
185 buildBatchReportTemplateTimeSpan() {
186 var o = new api.BatchReportTemplateTimeSpan();
187 buildCounterBatchReportTemplateTimeSpan++;
188 if (buildCounterBatchReportTemplateTimeSpan < 3) {
189 o.endTime = core.DateTime.parse("2002-02-27T14:01:02");
190 o.startTime = core.DateTime.parse("2002-02-27T14:01:02");
191 }
192 buildCounterBatchReportTemplateTimeSpan--;
193 return o;
194 }
195
196 checkBatchReportTemplateTimeSpan(api.BatchReportTemplateTimeSpan o) {
197 buildCounterBatchReportTemplateTimeSpan++;
198 if (buildCounterBatchReportTemplateTimeSpan < 3) {
199 unittest.expect(o.endTime, unittest.equals(core.DateTime.parse("2002-02-27T1 4:01:02")));
200 unittest.expect(o.startTime, unittest.equals(core.DateTime.parse("2002-02-27 T14:01:02")));
201 }
202 buildCounterBatchReportTemplateTimeSpan--;
203 }
204
205 core.int buildCounterBatchReportTemplate = 0;
206 buildBatchReportTemplate() {
207 var o = new api.BatchReportTemplate();
208 buildCounterBatchReportTemplate++;
209 if (buildCounterBatchReportTemplate < 3) {
210 o.id = "foo";
211 o.outputs = buildUnnamed207();
212 o.reportId = "foo";
213 o.timeSpan = buildBatchReportTemplateTimeSpan();
214 o.timeUpdated = core.DateTime.parse("2002-02-27T14:01:02");
215 }
216 buildCounterBatchReportTemplate--;
217 return o;
218 }
219
220 checkBatchReportTemplate(api.BatchReportTemplate o) {
221 buildCounterBatchReportTemplate++;
222 if (buildCounterBatchReportTemplate < 3) {
223 unittest.expect(o.id, unittest.equals('foo'));
224 checkUnnamed207(o.outputs);
225 unittest.expect(o.reportId, unittest.equals('foo'));
226 checkBatchReportTemplateTimeSpan(o.timeSpan);
227 unittest.expect(o.timeUpdated, unittest.equals(core.DateTime.parse("2002-02- 27T14:01:02")));
228 }
229 buildCounterBatchReportTemplate--;
230 }
231
232 core.int buildCounterResultTableColumnHeaders = 0;
233 buildResultTableColumnHeaders() {
234 var o = new api.ResultTableColumnHeaders();
235 buildCounterResultTableColumnHeaders++;
236 if (buildCounterResultTableColumnHeaders < 3) {
237 o.columnType = "foo";
238 o.dataType = "foo";
239 o.name = "foo";
240 }
241 buildCounterResultTableColumnHeaders--;
242 return o;
243 }
244
245 checkResultTableColumnHeaders(api.ResultTableColumnHeaders o) {
246 buildCounterResultTableColumnHeaders++;
247 if (buildCounterResultTableColumnHeaders < 3) {
248 unittest.expect(o.columnType, unittest.equals('foo'));
249 unittest.expect(o.dataType, unittest.equals('foo'));
250 unittest.expect(o.name, unittest.equals('foo'));
251 }
252 buildCounterResultTableColumnHeaders--;
253 }
254
255 buildUnnamed208() {
256 var o = new core.List<api.ResultTableColumnHeaders>();
257 o.add(buildResultTableColumnHeaders());
258 o.add(buildResultTableColumnHeaders());
259 return o;
260 }
261
262 checkUnnamed208(core.List<api.ResultTableColumnHeaders> o) {
263 unittest.expect(o, unittest.hasLength(2));
264 checkResultTableColumnHeaders(o[0]);
265 checkResultTableColumnHeaders(o[1]);
266 }
267
268 buildUnnamed209() {
269 var o = new core.List<core.Object>();
270 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'});
271 o.add({'list' : [1, 2, 3], 'bool' : true, 'string' : 'foo'});
272 return o;
273 }
274
275 checkUnnamed209(core.List<core.Object> o) {
276 unittest.expect(o, unittest.hasLength(2));
277 var casted1 = (o[0]) as core.Map; unittest.expect(casted1, unittest.hasLength( 3)); unittest.expect(casted1["list"], unittest.equals([1, 2, 3])); unittest.expe ct(casted1["bool"], unittest.equals(true)); unittest.expect(casted1["string"], u nittest.equals('foo'));
278 var casted2 = (o[1]) as core.Map; unittest.expect(casted2, unittest.hasLength( 3)); unittest.expect(casted2["list"], unittest.equals([1, 2, 3])); unittest.expe ct(casted2["bool"], unittest.equals(true)); unittest.expect(casted2["string"], u nittest.equals('foo'));
279 }
280
281 buildUnnamed210() {
282 var o = new core.List<core.List<core.Object>>();
283 o.add(buildUnnamed209());
284 o.add(buildUnnamed209());
285 return o;
286 }
287
288 checkUnnamed210(core.List<core.List<core.Object>> o) {
289 unittest.expect(o, unittest.hasLength(2));
290 checkUnnamed209(o[0]);
291 checkUnnamed209(o[1]);
292 }
293
294 core.int buildCounterResultTable = 0;
295 buildResultTable() {
296 var o = new api.ResultTable();
297 buildCounterResultTable++;
298 if (buildCounterResultTable < 3) {
299 o.columnHeaders = buildUnnamed208();
300 o.kind = "foo";
301 o.rows = buildUnnamed210();
302 }
303 buildCounterResultTable--;
304 return o;
305 }
306
307 checkResultTable(api.ResultTable o) {
308 buildCounterResultTable++;
309 if (buildCounterResultTable < 3) {
310 checkUnnamed208(o.columnHeaders);
311 unittest.expect(o.kind, unittest.equals('foo'));
312 checkUnnamed210(o.rows);
313 }
314 buildCounterResultTable--;
315 }
316
317
318 main() {
319 unittest.group("obj-schema-BatchReportDefinitionList", () {
320 unittest.test("to-json--from-json", () {
321 var o = buildBatchReportDefinitionList();
322 var od = new api.BatchReportDefinitionList.fromJson(o.toJson());
323 checkBatchReportDefinitionList(od);
324 });
325 });
326
327
328 unittest.group("obj-schema-BatchReportDefinitionTemplateDefaultOutput", () {
329 unittest.test("to-json--from-json", () {
330 var o = buildBatchReportDefinitionTemplateDefaultOutput();
331 var od = new api.BatchReportDefinitionTemplateDefaultOutput.fromJson(o.toJ son());
332 checkBatchReportDefinitionTemplateDefaultOutput(od);
333 });
334 });
335
336
337 unittest.group("obj-schema-BatchReportDefinitionTemplate", () {
338 unittest.test("to-json--from-json", () {
339 var o = buildBatchReportDefinitionTemplate();
340 var od = new api.BatchReportDefinitionTemplate.fromJson(o.toJson());
341 checkBatchReportDefinitionTemplate(od);
342 });
343 });
344
345
346 unittest.group("obj-schema-BatchReportList", () {
347 unittest.test("to-json--from-json", () {
348 var o = buildBatchReportList();
349 var od = new api.BatchReportList.fromJson(o.toJson());
350 checkBatchReportList(od);
351 });
352 });
353
354
355 unittest.group("obj-schema-BatchReportTemplateOutputs", () {
356 unittest.test("to-json--from-json", () {
357 var o = buildBatchReportTemplateOutputs();
358 var od = new api.BatchReportTemplateOutputs.fromJson(o.toJson());
359 checkBatchReportTemplateOutputs(od);
360 });
361 });
362
363
364 unittest.group("obj-schema-BatchReportTemplateTimeSpan", () {
365 unittest.test("to-json--from-json", () {
366 var o = buildBatchReportTemplateTimeSpan();
367 var od = new api.BatchReportTemplateTimeSpan.fromJson(o.toJson());
368 checkBatchReportTemplateTimeSpan(od);
369 });
370 });
371
372
373 unittest.group("obj-schema-BatchReportTemplate", () {
374 unittest.test("to-json--from-json", () {
375 var o = buildBatchReportTemplate();
376 var od = new api.BatchReportTemplate.fromJson(o.toJson());
377 checkBatchReportTemplate(od);
378 });
379 });
380
381
382 unittest.group("obj-schema-ResultTableColumnHeaders", () {
383 unittest.test("to-json--from-json", () {
384 var o = buildResultTableColumnHeaders();
385 var od = new api.ResultTableColumnHeaders.fromJson(o.toJson());
386 checkResultTableColumnHeaders(od);
387 });
388 });
389
390
391 unittest.group("obj-schema-ResultTable", () {
392 unittest.test("to-json--from-json", () {
393 var o = buildResultTable();
394 var od = new api.ResultTable.fromJson(o.toJson());
395 checkResultTable(od);
396 });
397 });
398
399
400 unittest.group("resource-BatchReportDefinitionsResourceApi", () {
401 unittest.test("method--list", () {
402
403 var mock = new common_test.HttpServerMock();
404 api.BatchReportDefinitionsResourceApi res = new api.YoutubeAnalyticsApi(mo ck).batchReportDefinitions;
405 var arg_onBehalfOfContentOwner = "foo";
406 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
407 var path = (req.url).path;
408 var pathOffset = 0;
409 var index;
410 var subPart;
411 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq uals("/youtube/analytics/v1/"));
412 pathOffset += 22;
413 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq uals("batchReportDefinitions"));
414 pathOffset += 22;
415
416 var query = (req.url).query;
417 var queryOffset = 0;
418 var queryMap = {};
419 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
420 parseBool(n) {
421 if (n == "true") return true;
422 if (n == "false") return false;
423 if (n == null) return null;
424 throw new core.ArgumentError("Invalid boolean: $n");
425 }
426 if (query.length > 0) {
427 for (var part in query.split("&")) {
428 var keyvalue = part.split("=");
429 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
430 }
431 }
432 unittest.expect(queryMap["onBehalfOfContentOwner"].first, unittest.equal s(arg_onBehalfOfContentOwner));
433
434
435 var h = {
436 "content-type" : "application/json; charset=utf-8",
437 };
438 var resp = convert.JSON.encode(buildBatchReportDefinitionList());
439 return new async.Future.value(common_test.stringResponse(200, h, resp));
440 }), true);
441 res.list(arg_onBehalfOfContentOwner).then(unittest.expectAsync(((api.Batch ReportDefinitionList response) {
442 checkBatchReportDefinitionList(response);
443 })));
444 });
445
446 });
447
448
449 unittest.group("resource-BatchReportsResourceApi", () {
450 unittest.test("method--list", () {
451
452 var mock = new common_test.HttpServerMock();
453 api.BatchReportsResourceApi res = new api.YoutubeAnalyticsApi(mock).batchR eports;
454 var arg_batchReportDefinitionId = "foo";
455 var arg_onBehalfOfContentOwner = "foo";
456 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
457 var path = (req.url).path;
458 var pathOffset = 0;
459 var index;
460 var subPart;
461 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq uals("/youtube/analytics/v1/"));
462 pathOffset += 22;
463 unittest.expect(path.substring(pathOffset, pathOffset + 12), unittest.eq uals("batchReports"));
464 pathOffset += 12;
465
466 var query = (req.url).query;
467 var queryOffset = 0;
468 var queryMap = {};
469 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
470 parseBool(n) {
471 if (n == "true") return true;
472 if (n == "false") return false;
473 if (n == null) return null;
474 throw new core.ArgumentError("Invalid boolean: $n");
475 }
476 if (query.length > 0) {
477 for (var part in query.split("&")) {
478 var keyvalue = part.split("=");
479 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
480 }
481 }
482 unittest.expect(queryMap["batchReportDefinitionId"].first, unittest.equa ls(arg_batchReportDefinitionId));
483 unittest.expect(queryMap["onBehalfOfContentOwner"].first, unittest.equal s(arg_onBehalfOfContentOwner));
484
485
486 var h = {
487 "content-type" : "application/json; charset=utf-8",
488 };
489 var resp = convert.JSON.encode(buildBatchReportList());
490 return new async.Future.value(common_test.stringResponse(200, h, resp));
491 }), true);
492 res.list(arg_batchReportDefinitionId, arg_onBehalfOfContentOwner).then(uni ttest.expectAsync(((api.BatchReportList response) {
493 checkBatchReportList(response);
494 })));
495 });
496
497 });
498
499
500 unittest.group("resource-ReportsResourceApi", () {
501 unittest.test("method--query", () {
502
503 var mock = new common_test.HttpServerMock();
504 api.ReportsResourceApi res = new api.YoutubeAnalyticsApi(mock).reports;
505 var arg_ids = "foo";
506 var arg_start_date = "foo";
507 var arg_end_date = "foo";
508 var arg_metrics = "foo";
509 var arg_dimensions = "foo";
510 var arg_filters = "foo";
511 var arg_max_results = 42;
512 var arg_sort = "foo";
513 var arg_start_index = 42;
514 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
515 var path = (req.url).path;
516 var pathOffset = 0;
517 var index;
518 var subPart;
519 unittest.expect(path.substring(pathOffset, pathOffset + 22), unittest.eq uals("/youtube/analytics/v1/"));
520 pathOffset += 22;
521 unittest.expect(path.substring(pathOffset, pathOffset + 7), unittest.equ als("reports"));
522 pathOffset += 7;
523
524 var query = (req.url).query;
525 var queryOffset = 0;
526 var queryMap = {};
527 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
528 parseBool(n) {
529 if (n == "true") return true;
530 if (n == "false") return false;
531 if (n == null) return null;
532 throw new core.ArgumentError("Invalid boolean: $n");
533 }
534 if (query.length > 0) {
535 for (var part in query.split("&")) {
536 var keyvalue = part.split("=");
537 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
538 }
539 }
540 unittest.expect(queryMap["ids"].first, unittest.equals(arg_ids));
541 unittest.expect(queryMap["start-date"].first, unittest.equals(arg_start_ date));
542 unittest.expect(queryMap["end-date"].first, unittest.equals(arg_end_date ));
543 unittest.expect(queryMap["metrics"].first, unittest.equals(arg_metrics)) ;
544 unittest.expect(queryMap["dimensions"].first, unittest.equals(arg_dimens ions));
545 unittest.expect(queryMap["filters"].first, unittest.equals(arg_filters)) ;
546 unittest.expect(core.int.parse(queryMap["max-results"].first), unittest. equals(arg_max_results));
547 unittest.expect(queryMap["sort"].first, unittest.equals(arg_sort));
548 unittest.expect(core.int.parse(queryMap["start-index"].first), unittest. equals(arg_start_index));
549
550
551 var h = {
552 "content-type" : "application/json; charset=utf-8",
553 };
554 var resp = convert.JSON.encode(buildResultTable());
555 return new async.Future.value(common_test.stringResponse(200, h, resp));
556 }), true);
557 res.query(arg_ids, arg_start_date, arg_end_date, arg_metrics, dimensions: arg_dimensions, filters: arg_filters, max_results: arg_max_results, sort: arg_so rt, start_index: arg_start_index).then(unittest.expectAsync(((api.ResultTable re sponse) {
558 checkResultTable(response);
559 })));
560 });
561
562 });
563
564
565 }
566
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698