| OLD | NEW |
| 1 library googleapis.youtubereporting.v1.test; | 1 library googleapis.youtubereporting.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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 unittest.expect(o.createTime, unittest.equals('foo')); | 90 unittest.expect(o.createTime, unittest.equals('foo')); |
| 91 unittest.expect(o.expireTime, unittest.equals('foo')); | 91 unittest.expect(o.expireTime, unittest.equals('foo')); |
| 92 unittest.expect(o.id, unittest.equals('foo')); | 92 unittest.expect(o.id, unittest.equals('foo')); |
| 93 unittest.expect(o.name, unittest.equals('foo')); | 93 unittest.expect(o.name, unittest.equals('foo')); |
| 94 unittest.expect(o.reportTypeId, unittest.equals('foo')); | 94 unittest.expect(o.reportTypeId, unittest.equals('foo')); |
| 95 unittest.expect(o.systemManaged, unittest.isTrue); | 95 unittest.expect(o.systemManaged, unittest.isTrue); |
| 96 } | 96 } |
| 97 buildCounterJob--; | 97 buildCounterJob--; |
| 98 } | 98 } |
| 99 | 99 |
| 100 buildUnnamed1085() { | 100 buildUnnamed1061() { |
| 101 var o = new core.List<api.Job>(); | 101 var o = new core.List<api.Job>(); |
| 102 o.add(buildJob()); | 102 o.add(buildJob()); |
| 103 o.add(buildJob()); | 103 o.add(buildJob()); |
| 104 return o; | 104 return o; |
| 105 } | 105 } |
| 106 | 106 |
| 107 checkUnnamed1085(core.List<api.Job> o) { | 107 checkUnnamed1061(core.List<api.Job> o) { |
| 108 unittest.expect(o, unittest.hasLength(2)); | 108 unittest.expect(o, unittest.hasLength(2)); |
| 109 checkJob(o[0]); | 109 checkJob(o[0]); |
| 110 checkJob(o[1]); | 110 checkJob(o[1]); |
| 111 } | 111 } |
| 112 | 112 |
| 113 core.int buildCounterListJobsResponse = 0; | 113 core.int buildCounterListJobsResponse = 0; |
| 114 buildListJobsResponse() { | 114 buildListJobsResponse() { |
| 115 var o = new api.ListJobsResponse(); | 115 var o = new api.ListJobsResponse(); |
| 116 buildCounterListJobsResponse++; | 116 buildCounterListJobsResponse++; |
| 117 if (buildCounterListJobsResponse < 3) { | 117 if (buildCounterListJobsResponse < 3) { |
| 118 o.jobs = buildUnnamed1085(); | 118 o.jobs = buildUnnamed1061(); |
| 119 o.nextPageToken = "foo"; | 119 o.nextPageToken = "foo"; |
| 120 } | 120 } |
| 121 buildCounterListJobsResponse--; | 121 buildCounterListJobsResponse--; |
| 122 return o; | 122 return o; |
| 123 } | 123 } |
| 124 | 124 |
| 125 checkListJobsResponse(api.ListJobsResponse o) { | 125 checkListJobsResponse(api.ListJobsResponse o) { |
| 126 buildCounterListJobsResponse++; | 126 buildCounterListJobsResponse++; |
| 127 if (buildCounterListJobsResponse < 3) { | 127 if (buildCounterListJobsResponse < 3) { |
| 128 checkUnnamed1085(o.jobs); | 128 checkUnnamed1061(o.jobs); |
| 129 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 129 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 130 } | 130 } |
| 131 buildCounterListJobsResponse--; | 131 buildCounterListJobsResponse--; |
| 132 } | 132 } |
| 133 | 133 |
| 134 buildUnnamed1086() { | 134 buildUnnamed1062() { |
| 135 var o = new core.List<api.ReportType>(); | 135 var o = new core.List<api.ReportType>(); |
| 136 o.add(buildReportType()); | 136 o.add(buildReportType()); |
| 137 o.add(buildReportType()); | 137 o.add(buildReportType()); |
| 138 return o; | 138 return o; |
| 139 } | 139 } |
| 140 | 140 |
| 141 checkUnnamed1086(core.List<api.ReportType> o) { | 141 checkUnnamed1062(core.List<api.ReportType> o) { |
| 142 unittest.expect(o, unittest.hasLength(2)); | 142 unittest.expect(o, unittest.hasLength(2)); |
| 143 checkReportType(o[0]); | 143 checkReportType(o[0]); |
| 144 checkReportType(o[1]); | 144 checkReportType(o[1]); |
| 145 } | 145 } |
| 146 | 146 |
| 147 core.int buildCounterListReportTypesResponse = 0; | 147 core.int buildCounterListReportTypesResponse = 0; |
| 148 buildListReportTypesResponse() { | 148 buildListReportTypesResponse() { |
| 149 var o = new api.ListReportTypesResponse(); | 149 var o = new api.ListReportTypesResponse(); |
| 150 buildCounterListReportTypesResponse++; | 150 buildCounterListReportTypesResponse++; |
| 151 if (buildCounterListReportTypesResponse < 3) { | 151 if (buildCounterListReportTypesResponse < 3) { |
| 152 o.nextPageToken = "foo"; | 152 o.nextPageToken = "foo"; |
| 153 o.reportTypes = buildUnnamed1086(); | 153 o.reportTypes = buildUnnamed1062(); |
| 154 } | 154 } |
| 155 buildCounterListReportTypesResponse--; | 155 buildCounterListReportTypesResponse--; |
| 156 return o; | 156 return o; |
| 157 } | 157 } |
| 158 | 158 |
| 159 checkListReportTypesResponse(api.ListReportTypesResponse o) { | 159 checkListReportTypesResponse(api.ListReportTypesResponse o) { |
| 160 buildCounterListReportTypesResponse++; | 160 buildCounterListReportTypesResponse++; |
| 161 if (buildCounterListReportTypesResponse < 3) { | 161 if (buildCounterListReportTypesResponse < 3) { |
| 162 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 162 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 163 checkUnnamed1086(o.reportTypes); | 163 checkUnnamed1062(o.reportTypes); |
| 164 } | 164 } |
| 165 buildCounterListReportTypesResponse--; | 165 buildCounterListReportTypesResponse--; |
| 166 } | 166 } |
| 167 | 167 |
| 168 buildUnnamed1087() { | 168 buildUnnamed1063() { |
| 169 var o = new core.List<api.Report>(); | 169 var o = new core.List<api.Report>(); |
| 170 o.add(buildReport()); | 170 o.add(buildReport()); |
| 171 o.add(buildReport()); | 171 o.add(buildReport()); |
| 172 return o; | 172 return o; |
| 173 } | 173 } |
| 174 | 174 |
| 175 checkUnnamed1087(core.List<api.Report> o) { | 175 checkUnnamed1063(core.List<api.Report> o) { |
| 176 unittest.expect(o, unittest.hasLength(2)); | 176 unittest.expect(o, unittest.hasLength(2)); |
| 177 checkReport(o[0]); | 177 checkReport(o[0]); |
| 178 checkReport(o[1]); | 178 checkReport(o[1]); |
| 179 } | 179 } |
| 180 | 180 |
| 181 core.int buildCounterListReportsResponse = 0; | 181 core.int buildCounterListReportsResponse = 0; |
| 182 buildListReportsResponse() { | 182 buildListReportsResponse() { |
| 183 var o = new api.ListReportsResponse(); | 183 var o = new api.ListReportsResponse(); |
| 184 buildCounterListReportsResponse++; | 184 buildCounterListReportsResponse++; |
| 185 if (buildCounterListReportsResponse < 3) { | 185 if (buildCounterListReportsResponse < 3) { |
| 186 o.nextPageToken = "foo"; | 186 o.nextPageToken = "foo"; |
| 187 o.reports = buildUnnamed1087(); | 187 o.reports = buildUnnamed1063(); |
| 188 } | 188 } |
| 189 buildCounterListReportsResponse--; | 189 buildCounterListReportsResponse--; |
| 190 return o; | 190 return o; |
| 191 } | 191 } |
| 192 | 192 |
| 193 checkListReportsResponse(api.ListReportsResponse o) { | 193 checkListReportsResponse(api.ListReportsResponse o) { |
| 194 buildCounterListReportsResponse++; | 194 buildCounterListReportsResponse++; |
| 195 if (buildCounterListReportsResponse < 3) { | 195 if (buildCounterListReportsResponse < 3) { |
| 196 unittest.expect(o.nextPageToken, unittest.equals('foo')); | 196 unittest.expect(o.nextPageToken, unittest.equals('foo')); |
| 197 checkUnnamed1087(o.reports); | 197 checkUnnamed1063(o.reports); |
| 198 } | 198 } |
| 199 buildCounterListReportsResponse--; | 199 buildCounterListReportsResponse--; |
| 200 } | 200 } |
| 201 | 201 |
| 202 core.int buildCounterMedia = 0; | 202 core.int buildCounterMedia = 0; |
| 203 buildMedia() { | 203 buildMedia() { |
| 204 var o = new api.Media(); | 204 var o = new api.Media(); |
| 205 buildCounterMedia++; | 205 buildCounterMedia++; |
| 206 if (buildCounterMedia < 3) { | 206 if (buildCounterMedia < 3) { |
| 207 o.resourceName = "foo"; | 207 o.resourceName = "foo"; |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 checkReport(response); | 607 checkReport(response); |
| 608 }))); | 608 }))); |
| 609 }); | 609 }); |
| 610 | 610 |
| 611 unittest.test("method--list", () { | 611 unittest.test("method--list", () { |
| 612 | 612 |
| 613 var mock = new HttpServerMock(); | 613 var mock = new HttpServerMock(); |
| 614 api.JobsReportsResourceApi res = new api.YoutubereportingApi(mock).jobs.re
ports; | 614 api.JobsReportsResourceApi res = new api.YoutubereportingApi(mock).jobs.re
ports; |
| 615 var arg_jobId = "foo"; | 615 var arg_jobId = "foo"; |
| 616 var arg_createdAfter = "foo"; | 616 var arg_createdAfter = "foo"; |
| 617 var arg_pageToken = "foo"; |
| 617 var arg_startTimeAtOrAfter = "foo"; | 618 var arg_startTimeAtOrAfter = "foo"; |
| 618 var arg_pageToken = "foo"; | |
| 619 var arg_pageSize = 42; | 619 var arg_pageSize = 42; |
| 620 var arg_onBehalfOfContentOwner = "foo"; | 620 var arg_onBehalfOfContentOwner = "foo"; |
| 621 var arg_startTimeBefore = "foo"; | 621 var arg_startTimeBefore = "foo"; |
| 622 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 622 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 623 var path = (req.url).path; | 623 var path = (req.url).path; |
| 624 var pathOffset = 0; | 624 var pathOffset = 0; |
| 625 var index; | 625 var index; |
| 626 var subPart; | 626 var subPart; |
| 627 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 627 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 628 pathOffset += 1; | 628 pathOffset += 1; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 646 if (n == null) return null; | 646 if (n == null) return null; |
| 647 throw new core.ArgumentError("Invalid boolean: $n"); | 647 throw new core.ArgumentError("Invalid boolean: $n"); |
| 648 } | 648 } |
| 649 if (query.length > 0) { | 649 if (query.length > 0) { |
| 650 for (var part in query.split("&")) { | 650 for (var part in query.split("&")) { |
| 651 var keyvalue = part.split("="); | 651 var keyvalue = part.split("="); |
| 652 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 652 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 unittest.expect(queryMap["createdAfter"].first, unittest.equals(arg_crea
tedAfter)); | 655 unittest.expect(queryMap["createdAfter"].first, unittest.equals(arg_crea
tedAfter)); |
| 656 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); |
| 656 unittest.expect(queryMap["startTimeAtOrAfter"].first, unittest.equals(ar
g_startTimeAtOrAfter)); | 657 unittest.expect(queryMap["startTimeAtOrAfter"].first, unittest.equals(ar
g_startTimeAtOrAfter)); |
| 657 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | |
| 658 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | 658 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); |
| 659 unittest.expect(queryMap["onBehalfOfContentOwner"].first, unittest.equal
s(arg_onBehalfOfContentOwner)); | 659 unittest.expect(queryMap["onBehalfOfContentOwner"].first, unittest.equal
s(arg_onBehalfOfContentOwner)); |
| 660 unittest.expect(queryMap["startTimeBefore"].first, unittest.equals(arg_s
tartTimeBefore)); | 660 unittest.expect(queryMap["startTimeBefore"].first, unittest.equals(arg_s
tartTimeBefore)); |
| 661 | 661 |
| 662 | 662 |
| 663 var h = { | 663 var h = { |
| 664 "content-type" : "application/json; charset=utf-8", | 664 "content-type" : "application/json; charset=utf-8", |
| 665 }; | 665 }; |
| 666 var resp = convert.JSON.encode(buildListReportsResponse()); | 666 var resp = convert.JSON.encode(buildListReportsResponse()); |
| 667 return new async.Future.value(stringResponse(200, h, resp)); | 667 return new async.Future.value(stringResponse(200, h, resp)); |
| 668 }), true); | 668 }), true); |
| 669 res.list(arg_jobId, createdAfter: arg_createdAfter, startTimeAtOrAfter: ar
g_startTimeAtOrAfter, pageToken: arg_pageToken, pageSize: arg_pageSize, onBehalf
OfContentOwner: arg_onBehalfOfContentOwner, startTimeBefore: arg_startTimeBefore
).then(unittest.expectAsync1(((api.ListReportsResponse response) { | 669 res.list(arg_jobId, createdAfter: arg_createdAfter, pageToken: arg_pageTok
en, startTimeAtOrAfter: arg_startTimeAtOrAfter, pageSize: arg_pageSize, onBehalf
OfContentOwner: arg_onBehalfOfContentOwner, startTimeBefore: arg_startTimeBefore
).then(unittest.expectAsync1(((api.ListReportsResponse response) { |
| 670 checkListReportsResponse(response); | 670 checkListReportsResponse(response); |
| 671 }))); | 671 }))); |
| 672 }); | 672 }); |
| 673 | 673 |
| 674 }); | 674 }); |
| 675 | 675 |
| 676 | 676 |
| 677 unittest.group("resource-MediaResourceApi", () { | 677 unittest.group("resource-MediaResourceApi", () { |
| 678 unittest.test("method--download", () { | 678 unittest.test("method--download", () { |
| 679 // TODO: Implement tests for media upload; | 679 // TODO: Implement tests for media upload; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 }); | 723 }); |
| 724 | 724 |
| 725 }); | 725 }); |
| 726 | 726 |
| 727 | 727 |
| 728 unittest.group("resource-ReportTypesResourceApi", () { | 728 unittest.group("resource-ReportTypesResourceApi", () { |
| 729 unittest.test("method--list", () { | 729 unittest.test("method--list", () { |
| 730 | 730 |
| 731 var mock = new HttpServerMock(); | 731 var mock = new HttpServerMock(); |
| 732 api.ReportTypesResourceApi res = new api.YoutubereportingApi(mock).reportT
ypes; | 732 api.ReportTypesResourceApi res = new api.YoutubereportingApi(mock).reportT
ypes; |
| 733 var arg_onBehalfOfContentOwner = "foo"; |
| 733 var arg_includeSystemManaged = true; | 734 var arg_includeSystemManaged = true; |
| 734 var arg_pageToken = "foo"; | 735 var arg_pageToken = "foo"; |
| 735 var arg_pageSize = 42; | 736 var arg_pageSize = 42; |
| 736 var arg_onBehalfOfContentOwner = "foo"; | |
| 737 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { | 737 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { |
| 738 var path = (req.url).path; | 738 var path = (req.url).path; |
| 739 var pathOffset = 0; | 739 var pathOffset = 0; |
| 740 var index; | 740 var index; |
| 741 var subPart; | 741 var subPart; |
| 742 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); | 742 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ
als("/")); |
| 743 pathOffset += 1; | 743 pathOffset += 1; |
| 744 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("v1/reportTypes")); | 744 unittest.expect(path.substring(pathOffset, pathOffset + 14), unittest.eq
uals("v1/reportTypes")); |
| 745 pathOffset += 14; | 745 pathOffset += 14; |
| 746 | 746 |
| 747 var query = (req.url).query; | 747 var query = (req.url).query; |
| 748 var queryOffset = 0; | 748 var queryOffset = 0; |
| 749 var queryMap = {}; | 749 var queryMap = {}; |
| 750 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | 750 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); |
| 751 parseBool(n) { | 751 parseBool(n) { |
| 752 if (n == "true") return true; | 752 if (n == "true") return true; |
| 753 if (n == "false") return false; | 753 if (n == "false") return false; |
| 754 if (n == null) return null; | 754 if (n == null) return null; |
| 755 throw new core.ArgumentError("Invalid boolean: $n"); | 755 throw new core.ArgumentError("Invalid boolean: $n"); |
| 756 } | 756 } |
| 757 if (query.length > 0) { | 757 if (query.length > 0) { |
| 758 for (var part in query.split("&")) { | 758 for (var part in query.split("&")) { |
| 759 var keyvalue = part.split("="); | 759 var keyvalue = part.split("="); |
| 760 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | 760 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); |
| 761 } | 761 } |
| 762 } | 762 } |
| 763 unittest.expect(queryMap["onBehalfOfContentOwner"].first, unittest.equal
s(arg_onBehalfOfContentOwner)); |
| 763 unittest.expect(queryMap["includeSystemManaged"].first, unittest.equals(
"$arg_includeSystemManaged")); | 764 unittest.expect(queryMap["includeSystemManaged"].first, unittest.equals(
"$arg_includeSystemManaged")); |
| 764 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); | 765 unittest.expect(queryMap["pageToken"].first, unittest.equals(arg_pageTok
en)); |
| 765 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); | 766 unittest.expect(core.int.parse(queryMap["pageSize"].first), unittest.equ
als(arg_pageSize)); |
| 766 unittest.expect(queryMap["onBehalfOfContentOwner"].first, unittest.equal
s(arg_onBehalfOfContentOwner)); | |
| 767 | 767 |
| 768 | 768 |
| 769 var h = { | 769 var h = { |
| 770 "content-type" : "application/json; charset=utf-8", | 770 "content-type" : "application/json; charset=utf-8", |
| 771 }; | 771 }; |
| 772 var resp = convert.JSON.encode(buildListReportTypesResponse()); | 772 var resp = convert.JSON.encode(buildListReportTypesResponse()); |
| 773 return new async.Future.value(stringResponse(200, h, resp)); | 773 return new async.Future.value(stringResponse(200, h, resp)); |
| 774 }), true); | 774 }), true); |
| 775 res.list(includeSystemManaged: arg_includeSystemManaged, pageToken: arg_pa
geToken, pageSize: arg_pageSize, onBehalfOfContentOwner: arg_onBehalfOfContentOw
ner).then(unittest.expectAsync1(((api.ListReportTypesResponse response) { | 775 res.list(onBehalfOfContentOwner: arg_onBehalfOfContentOwner, includeSystem
Managed: arg_includeSystemManaged, pageToken: arg_pageToken, pageSize: arg_pageS
ize).then(unittest.expectAsync1(((api.ListReportTypesResponse response) { |
| 776 checkListReportTypesResponse(response); | 776 checkListReportTypesResponse(response); |
| 777 }))); | 777 }))); |
| 778 }); | 778 }); |
| 779 | 779 |
| 780 }); | 780 }); |
| 781 | 781 |
| 782 | 782 |
| 783 } | 783 } |
| 784 | 784 |
| OLD | NEW |