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

Side by Side Diff: generated/googleapis/test/admin/email_migration_v2.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.admin.email_migration_v2.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/admin/email_migration_v2.dart' as api;
16
17
18
19 buildUnnamed0() {
20 var o = new core.List<core.String>();
21 o.add("foo");
22 o.add("foo");
23 return o;
24 }
25
26 checkUnnamed0(core.List<core.String> o) {
27 unittest.expect(o, unittest.hasLength(2));
28 unittest.expect(o[0], unittest.equals('foo'));
29 unittest.expect(o[1], unittest.equals('foo'));
30 }
31
32 core.int buildCounterMailItem = 0;
33 buildMailItem() {
34 var o = new api.MailItem();
35 buildCounterMailItem++;
36 if (buildCounterMailItem < 3) {
37 o.isDeleted = true;
38 o.isDraft = true;
39 o.isInbox = true;
40 o.isSent = true;
41 o.isStarred = true;
42 o.isTrash = true;
43 o.isUnread = true;
44 o.kind = "foo";
45 o.labels = buildUnnamed0();
46 }
47 buildCounterMailItem--;
48 return o;
49 }
50
51 checkMailItem(api.MailItem o) {
52 buildCounterMailItem++;
53 if (buildCounterMailItem < 3) {
54 unittest.expect(o.isDeleted, unittest.isTrue);
55 unittest.expect(o.isDraft, unittest.isTrue);
56 unittest.expect(o.isInbox, unittest.isTrue);
57 unittest.expect(o.isSent, unittest.isTrue);
58 unittest.expect(o.isStarred, unittest.isTrue);
59 unittest.expect(o.isTrash, unittest.isTrue);
60 unittest.expect(o.isUnread, unittest.isTrue);
61 unittest.expect(o.kind, unittest.equals('foo'));
62 checkUnnamed0(o.labels);
63 }
64 buildCounterMailItem--;
65 }
66
67
68 main() {
69 unittest.group("obj-schema-MailItem", () {
70 unittest.test("to-json--from-json", () {
71 var o = buildMailItem();
72 var od = new api.MailItem.fromJson(o.toJson());
73 checkMailItem(od);
74 });
75 });
76
77
78 unittest.group("resource-MailResourceApi", () {
79 unittest.test("method--insert", () {
80 // TODO: Implement tests for media upload;
81 // TODO: Implement tests for media download;
82
83 var mock = new common_test.HttpServerMock();
84 api.MailResourceApi res = new api.AdminApi(mock).mail;
85 var arg_request = buildMailItem();
86 var arg_userKey = "foo";
87 mock.register(unittest.expectAsync((http.BaseRequest req, json) {
88 var obj = new api.MailItem.fromJson(json);
89 checkMailItem(obj);
90
91 var path = (req.url).path;
92 var pathOffset = 0;
93 var index;
94 var subPart;
95 unittest.expect(path.substring(pathOffset, pathOffset + 16), unittest.eq uals("/email/v2/users/"));
96 pathOffset += 16;
97 index = path.indexOf("/mail", pathOffset);
98 unittest.expect(index >= 0, unittest.isTrue);
99 subPart = core.Uri.decodeQueryComponent(path.substring(pathOffset, index ));
100 pathOffset = index;
101 unittest.expect(subPart, unittest.equals("$arg_userKey"));
102 unittest.expect(path.substring(pathOffset, pathOffset + 5), unittest.equ als("/mail"));
103 pathOffset += 5;
104
105 var query = (req.url).query;
106 var queryOffset = 0;
107 var queryMap = {};
108 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
109 parseBool(n) {
110 if (n == "true") return true;
111 if (n == "false") return false;
112 if (n == null) return null;
113 throw new core.ArgumentError("Invalid boolean: $n");
114 }
115 if (query.length > 0) {
116 for (var part in query.split("&")) {
117 var keyvalue = part.split("=");
118 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1]));
119 }
120 }
121
122
123 var h = {
124 "content-type" : "application/json; charset=utf-8",
125 };
126 var resp = "";
127 return new async.Future.value(common_test.stringResponse(200, h, resp));
128 }), true);
129 res.insert(arg_request, arg_userKey).then(unittest.expectAsync((_) {}));
130 });
131
132 });
133
134
135 }
136
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698