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

Side by Side Diff: generated/googleapis_beta/test/oslogin/v1alpha_test.dart

Issue 3006323002: Api-Roll 54: 2017-09-11 (Closed)
Patch Set: use 2.0.0-dev.infinity sdk constraint in pubspecs Created 3 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
1 library googleapis_beta.oslogin.v1alpha.test; 1 library googleapis_beta.oslogin.v1alpha.test;
2 2
3 import "dart:core" as core; 3 import "dart:core" as core;
4 import "dart:collection" as collection;
5 import "dart:async" as async; 4 import "dart:async" as async;
6 import "dart:convert" as convert; 5 import "dart:convert" as convert;
7 6
8 import 'package:http/http.dart' as http; 7 import 'package:http/http.dart' as http;
9 import 'package:http/testing.dart' as http_testing;
10 import 'package:test/test.dart' as unittest; 8 import 'package:test/test.dart' as unittest;
11 9
12 import 'package:googleapis_beta/oslogin/v1alpha.dart' as api; 10 import 'package:googleapis_beta/oslogin/v1alpha.dart' as api;
13 11
14 class HttpServerMock extends http.BaseClient { 12 class HttpServerMock extends http.BaseClient {
15 core.Function _callback; 13 core.Function _callback;
16 core.bool _expectJson; 14 core.bool _expectJson;
17 15
18 void register(core.Function callback, core.bool expectJson) { 16 void register(core.Function callback, core.bool expectJson) {
19 _callback = callback; 17 _callback = callback;
20 _expectJson = expectJson; 18 _expectJson = expectJson;
21 } 19 }
22 20
23 async.Future<http.StreamedResponse> send(http.BaseRequest request) { 21 async.Future<http.StreamedResponse> send(http.BaseRequest request) {
24 if (_expectJson) { 22 if (_expectJson) {
25 return request.finalize() 23 return request
24 .finalize()
26 .transform(convert.UTF8.decoder) 25 .transform(convert.UTF8.decoder)
27 .join('') 26 .join('')
28 .then((core.String jsonString) { 27 .then((core.String jsonString) {
29 if (jsonString.isEmpty) { 28 if (jsonString.isEmpty) {
30 return _callback(request, null); 29 return _callback(request, null);
31 } else { 30 } else {
32 return _callback(request, convert.JSON.decode(jsonString)); 31 return _callback(request, convert.JSON.decode(jsonString));
33 } 32 }
34 }); 33 });
35 } else { 34 } else {
36 var stream = request.finalize(); 35 var stream = request.finalize();
37 if (stream == null) { 36 if (stream == null) {
38 return _callback(request, []); 37 return _callback(request, []);
39 } else { 38 } else {
40 return stream.toBytes().then((data) { 39 return stream.toBytes().then((data) {
41 return _callback(request, data); 40 return _callback(request, data);
42 }); 41 });
43 } 42 }
44 } 43 }
45 } 44 }
46 } 45 }
47 46
48 http.StreamedResponse stringResponse( 47 http.StreamedResponse stringResponse(core.int status,
49 core.int status, core.Map<core.String, core.String> headers, core.String bod y) { 48 core.Map<core.String, core.String> headers, core.String body) {
50 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]); 49 var stream = new async.Stream.fromIterable([convert.UTF8.encode(body)]);
51 return new http.StreamedResponse(stream, status, headers: headers); 50 return new http.StreamedResponse(stream, status, headers: headers);
52 } 51 }
53 52
54 core.int buildCounterEmpty = 0; 53 core.int buildCounterEmpty = 0;
55 buildEmpty() { 54 buildEmpty() {
56 var o = new api.Empty(); 55 var o = new api.Empty();
57 buildCounterEmpty++; 56 buildCounterEmpty++;
58 if (buildCounterEmpty < 3) { 57 if (buildCounterEmpty < 3) {}
59 }
60 buildCounterEmpty--; 58 buildCounterEmpty--;
61 return o; 59 return o;
62 } 60 }
63 61
64 checkEmpty(api.Empty o) { 62 checkEmpty(api.Empty o) {
65 buildCounterEmpty++; 63 buildCounterEmpty++;
66 if (buildCounterEmpty < 3) { 64 if (buildCounterEmpty < 3) {}
67 }
68 buildCounterEmpty--; 65 buildCounterEmpty--;
69 } 66 }
70 67
71 core.int buildCounterImportSshPublicKeyResponse = 0; 68 core.int buildCounterImportSshPublicKeyResponse = 0;
72 buildImportSshPublicKeyResponse() { 69 buildImportSshPublicKeyResponse() {
73 var o = new api.ImportSshPublicKeyResponse(); 70 var o = new api.ImportSshPublicKeyResponse();
74 buildCounterImportSshPublicKeyResponse++; 71 buildCounterImportSshPublicKeyResponse++;
75 if (buildCounterImportSshPublicKeyResponse < 3) { 72 if (buildCounterImportSshPublicKeyResponse < 3) {
76 o.loginProfile = buildLoginProfile(); 73 o.loginProfile = buildLoginProfile();
77 } 74 }
78 buildCounterImportSshPublicKeyResponse--; 75 buildCounterImportSshPublicKeyResponse--;
79 return o; 76 return o;
80 } 77 }
81 78
82 checkImportSshPublicKeyResponse(api.ImportSshPublicKeyResponse o) { 79 checkImportSshPublicKeyResponse(api.ImportSshPublicKeyResponse o) {
83 buildCounterImportSshPublicKeyResponse++; 80 buildCounterImportSshPublicKeyResponse++;
84 if (buildCounterImportSshPublicKeyResponse < 3) { 81 if (buildCounterImportSshPublicKeyResponse < 3) {
85 checkLoginProfile(o.loginProfile); 82 checkLoginProfile(o.loginProfile);
86 } 83 }
87 buildCounterImportSshPublicKeyResponse--; 84 buildCounterImportSshPublicKeyResponse--;
88 } 85 }
89 86
90 buildUnnamed3424() { 87 buildUnnamed3429() {
91 var o = new core.List<api.PosixAccount>(); 88 var o = new core.List<api.PosixAccount>();
92 o.add(buildPosixAccount()); 89 o.add(buildPosixAccount());
93 o.add(buildPosixAccount()); 90 o.add(buildPosixAccount());
94 return o; 91 return o;
95 } 92 }
96 93
97 checkUnnamed3424(core.List<api.PosixAccount> o) { 94 checkUnnamed3429(core.List<api.PosixAccount> o) {
98 unittest.expect(o, unittest.hasLength(2)); 95 unittest.expect(o, unittest.hasLength(2));
99 checkPosixAccount(o[0]); 96 checkPosixAccount(o[0]);
100 checkPosixAccount(o[1]); 97 checkPosixAccount(o[1]);
101 } 98 }
102 99
103 buildUnnamed3425() { 100 buildUnnamed3430() {
104 var o = new core.Map<core.String, api.SshPublicKey>(); 101 var o = new core.Map<core.String, api.SshPublicKey>();
105 o["x"] = buildSshPublicKey(); 102 o["x"] = buildSshPublicKey();
106 o["y"] = buildSshPublicKey(); 103 o["y"] = buildSshPublicKey();
107 return o; 104 return o;
108 } 105 }
109 106
110 checkUnnamed3425(core.Map<core.String, api.SshPublicKey> o) { 107 checkUnnamed3430(core.Map<core.String, api.SshPublicKey> o) {
111 unittest.expect(o, unittest.hasLength(2)); 108 unittest.expect(o, unittest.hasLength(2));
112 checkSshPublicKey(o["x"]); 109 checkSshPublicKey(o["x"]);
113 checkSshPublicKey(o["y"]); 110 checkSshPublicKey(o["y"]);
114 } 111 }
115 112
116 core.int buildCounterLoginProfile = 0; 113 core.int buildCounterLoginProfile = 0;
117 buildLoginProfile() { 114 buildLoginProfile() {
118 var o = new api.LoginProfile(); 115 var o = new api.LoginProfile();
119 buildCounterLoginProfile++; 116 buildCounterLoginProfile++;
120 if (buildCounterLoginProfile < 3) { 117 if (buildCounterLoginProfile < 3) {
121 o.name = "foo"; 118 o.name = "foo";
122 o.posixAccounts = buildUnnamed3424(); 119 o.posixAccounts = buildUnnamed3429();
123 o.sshPublicKeys = buildUnnamed3425(); 120 o.sshPublicKeys = buildUnnamed3430();
124 o.suspended = true; 121 o.suspended = true;
125 } 122 }
126 buildCounterLoginProfile--; 123 buildCounterLoginProfile--;
127 return o; 124 return o;
128 } 125 }
129 126
130 checkLoginProfile(api.LoginProfile o) { 127 checkLoginProfile(api.LoginProfile o) {
131 buildCounterLoginProfile++; 128 buildCounterLoginProfile++;
132 if (buildCounterLoginProfile < 3) { 129 if (buildCounterLoginProfile < 3) {
133 unittest.expect(o.name, unittest.equals('foo')); 130 unittest.expect(o.name, unittest.equals('foo'));
134 checkUnnamed3424(o.posixAccounts); 131 checkUnnamed3429(o.posixAccounts);
135 checkUnnamed3425(o.sshPublicKeys); 132 checkUnnamed3430(o.sshPublicKeys);
136 unittest.expect(o.suspended, unittest.isTrue); 133 unittest.expect(o.suspended, unittest.isTrue);
137 } 134 }
138 buildCounterLoginProfile--; 135 buildCounterLoginProfile--;
139 } 136 }
140 137
141 core.int buildCounterPosixAccount = 0; 138 core.int buildCounterPosixAccount = 0;
142 buildPosixAccount() { 139 buildPosixAccount() {
143 var o = new api.PosixAccount(); 140 var o = new api.PosixAccount();
144 buildCounterPosixAccount++; 141 buildCounterPosixAccount++;
145 if (buildCounterPosixAccount < 3) { 142 if (buildCounterPosixAccount < 3) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 checkSshPublicKey(api.SshPublicKey o) { 184 checkSshPublicKey(api.SshPublicKey o) {
188 buildCounterSshPublicKey++; 185 buildCounterSshPublicKey++;
189 if (buildCounterSshPublicKey < 3) { 186 if (buildCounterSshPublicKey < 3) {
190 unittest.expect(o.expirationTimeUsec, unittest.equals('foo')); 187 unittest.expect(o.expirationTimeUsec, unittest.equals('foo'));
191 unittest.expect(o.fingerprint, unittest.equals('foo')); 188 unittest.expect(o.fingerprint, unittest.equals('foo'));
192 unittest.expect(o.key, unittest.equals('foo')); 189 unittest.expect(o.key, unittest.equals('foo'));
193 } 190 }
194 buildCounterSshPublicKey--; 191 buildCounterSshPublicKey--;
195 } 192 }
196 193
197
198 main() { 194 main() {
199 unittest.group("obj-schema-Empty", () { 195 unittest.group("obj-schema-Empty", () {
200 unittest.test("to-json--from-json", () { 196 unittest.test("to-json--from-json", () {
201 var o = buildEmpty(); 197 var o = buildEmpty();
202 var od = new api.Empty.fromJson(o.toJson()); 198 var od = new api.Empty.fromJson(o.toJson());
203 checkEmpty(od); 199 checkEmpty(od);
204 }); 200 });
205 }); 201 });
206 202
207
208 unittest.group("obj-schema-ImportSshPublicKeyResponse", () { 203 unittest.group("obj-schema-ImportSshPublicKeyResponse", () {
209 unittest.test("to-json--from-json", () { 204 unittest.test("to-json--from-json", () {
210 var o = buildImportSshPublicKeyResponse(); 205 var o = buildImportSshPublicKeyResponse();
211 var od = new api.ImportSshPublicKeyResponse.fromJson(o.toJson()); 206 var od = new api.ImportSshPublicKeyResponse.fromJson(o.toJson());
212 checkImportSshPublicKeyResponse(od); 207 checkImportSshPublicKeyResponse(od);
213 }); 208 });
214 }); 209 });
215 210
216
217 unittest.group("obj-schema-LoginProfile", () { 211 unittest.group("obj-schema-LoginProfile", () {
218 unittest.test("to-json--from-json", () { 212 unittest.test("to-json--from-json", () {
219 var o = buildLoginProfile(); 213 var o = buildLoginProfile();
220 var od = new api.LoginProfile.fromJson(o.toJson()); 214 var od = new api.LoginProfile.fromJson(o.toJson());
221 checkLoginProfile(od); 215 checkLoginProfile(od);
222 }); 216 });
223 }); 217 });
224 218
225
226 unittest.group("obj-schema-PosixAccount", () { 219 unittest.group("obj-schema-PosixAccount", () {
227 unittest.test("to-json--from-json", () { 220 unittest.test("to-json--from-json", () {
228 var o = buildPosixAccount(); 221 var o = buildPosixAccount();
229 var od = new api.PosixAccount.fromJson(o.toJson()); 222 var od = new api.PosixAccount.fromJson(o.toJson());
230 checkPosixAccount(od); 223 checkPosixAccount(od);
231 }); 224 });
232 }); 225 });
233 226
234
235 unittest.group("obj-schema-SshPublicKey", () { 227 unittest.group("obj-schema-SshPublicKey", () {
236 unittest.test("to-json--from-json", () { 228 unittest.test("to-json--from-json", () {
237 var o = buildSshPublicKey(); 229 var o = buildSshPublicKey();
238 var od = new api.SshPublicKey.fromJson(o.toJson()); 230 var od = new api.SshPublicKey.fromJson(o.toJson());
239 checkSshPublicKey(od); 231 checkSshPublicKey(od);
240 }); 232 });
241 }); 233 });
242 234
243
244 unittest.group("resource-UsersResourceApi", () { 235 unittest.group("resource-UsersResourceApi", () {
245 unittest.test("method--getLoginProfile", () { 236 unittest.test("method--getLoginProfile", () {
246
247 var mock = new HttpServerMock(); 237 var mock = new HttpServerMock();
248 api.UsersResourceApi res = new api.OsloginApi(mock).users; 238 api.UsersResourceApi res = new api.OsloginApi(mock).users;
249 var arg_name = "foo"; 239 var arg_name = "foo";
250 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 240 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
251 var path = (req.url).path; 241 var path = (req.url).path;
252 var pathOffset = 0; 242 var pathOffset = 0;
253 var index; 243 var index;
254 var subPart; 244 var subPart;
255 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 245 unittest.expect(
246 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
256 pathOffset += 1; 247 pathOffset += 1;
257 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ als("v1alpha/")); 248 unittest.expect(path.substring(pathOffset, pathOffset + 8),
249 unittest.equals("v1alpha/"));
258 pathOffset += 8; 250 pathOffset += 8;
259 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation; 251 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
260 252
261 var query = (req.url).query; 253 var query = (req.url).query;
262 var queryOffset = 0; 254 var queryOffset = 0;
263 var queryMap = {}; 255 var queryMap = {};
264 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 256 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
265 parseBool(n) { 257 parseBool(n) {
266 if (n == "true") return true; 258 if (n == "true") return true;
267 if (n == "false") return false; 259 if (n == "false") return false;
268 if (n == null) return null; 260 if (n == null) return null;
269 throw new core.ArgumentError("Invalid boolean: $n"); 261 throw new core.ArgumentError("Invalid boolean: $n");
270 } 262 }
263
271 if (query.length > 0) { 264 if (query.length > 0) {
272 for (var part in query.split("&")) { 265 for (var part in query.split("&")) {
273 var keyvalue = part.split("="); 266 var keyvalue = part.split("=");
274 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 267 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
268 core.Uri.decodeQueryComponent(keyvalue[1]));
275 } 269 }
276 } 270 }
277 271
278
279 var h = { 272 var h = {
280 "content-type" : "application/json; charset=utf-8", 273 "content-type": "application/json; charset=utf-8",
281 }; 274 };
282 var resp = convert.JSON.encode(buildLoginProfile()); 275 var resp = convert.JSON.encode(buildLoginProfile());
283 return new async.Future.value(stringResponse(200, h, resp)); 276 return new async.Future.value(stringResponse(200, h, resp));
284 }), true); 277 }), true);
285 res.getLoginProfile(arg_name).then(unittest.expectAsync1(((api.LoginProfil e response) { 278 res
279 .getLoginProfile(arg_name)
280 .then(unittest.expectAsync1(((api.LoginProfile response) {
286 checkLoginProfile(response); 281 checkLoginProfile(response);
287 }))); 282 })));
288 }); 283 });
289 284
290 unittest.test("method--importSshPublicKey", () { 285 unittest.test("method--importSshPublicKey", () {
291
292 var mock = new HttpServerMock(); 286 var mock = new HttpServerMock();
293 api.UsersResourceApi res = new api.OsloginApi(mock).users; 287 api.UsersResourceApi res = new api.OsloginApi(mock).users;
294 var arg_request = buildSshPublicKey(); 288 var arg_request = buildSshPublicKey();
295 var arg_parent = "foo"; 289 var arg_parent = "foo";
296 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 290 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
297 var obj = new api.SshPublicKey.fromJson(json); 291 var obj = new api.SshPublicKey.fromJson(json);
298 checkSshPublicKey(obj); 292 checkSshPublicKey(obj);
299 293
300 var path = (req.url).path; 294 var path = (req.url).path;
301 var pathOffset = 0; 295 var pathOffset = 0;
302 var index; 296 var index;
303 var subPart; 297 var subPart;
304 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 298 unittest.expect(
299 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
305 pathOffset += 1; 300 pathOffset += 1;
306 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ als("v1alpha/")); 301 unittest.expect(path.substring(pathOffset, pathOffset + 8),
302 unittest.equals("v1alpha/"));
307 pathOffset += 8; 303 pathOffset += 8;
308 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation; 304 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
309 305
310 var query = (req.url).query; 306 var query = (req.url).query;
311 var queryOffset = 0; 307 var queryOffset = 0;
312 var queryMap = {}; 308 var queryMap = {};
313 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 309 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
314 parseBool(n) { 310 parseBool(n) {
315 if (n == "true") return true; 311 if (n == "true") return true;
316 if (n == "false") return false; 312 if (n == "false") return false;
317 if (n == null) return null; 313 if (n == null) return null;
318 throw new core.ArgumentError("Invalid boolean: $n"); 314 throw new core.ArgumentError("Invalid boolean: $n");
319 } 315 }
316
320 if (query.length > 0) { 317 if (query.length > 0) {
321 for (var part in query.split("&")) { 318 for (var part in query.split("&")) {
322 var keyvalue = part.split("="); 319 var keyvalue = part.split("=");
323 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 320 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
321 core.Uri.decodeQueryComponent(keyvalue[1]));
324 } 322 }
325 } 323 }
326 324
327
328 var h = { 325 var h = {
329 "content-type" : "application/json; charset=utf-8", 326 "content-type": "application/json; charset=utf-8",
330 }; 327 };
331 var resp = convert.JSON.encode(buildImportSshPublicKeyResponse()); 328 var resp = convert.JSON.encode(buildImportSshPublicKeyResponse());
332 return new async.Future.value(stringResponse(200, h, resp)); 329 return new async.Future.value(stringResponse(200, h, resp));
333 }), true); 330 }), true);
334 res.importSshPublicKey(arg_request, arg_parent).then(unittest.expectAsync1 (((api.ImportSshPublicKeyResponse response) { 331 res.importSshPublicKey(arg_request, arg_parent).then(
332 unittest.expectAsync1(((api.ImportSshPublicKeyResponse response) {
335 checkImportSshPublicKeyResponse(response); 333 checkImportSshPublicKeyResponse(response);
336 }))); 334 })));
337 }); 335 });
338
339 }); 336 });
340 337
341
342 unittest.group("resource-UsersSshPublicKeysResourceApi", () { 338 unittest.group("resource-UsersSshPublicKeysResourceApi", () {
343 unittest.test("method--delete", () { 339 unittest.test("method--delete", () {
344
345 var mock = new HttpServerMock(); 340 var mock = new HttpServerMock();
346 api.UsersSshPublicKeysResourceApi res = new api.OsloginApi(mock).users.ssh PublicKeys; 341 api.UsersSshPublicKeysResourceApi res =
342 new api.OsloginApi(mock).users.sshPublicKeys;
347 var arg_name = "foo"; 343 var arg_name = "foo";
348 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 344 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
349 var path = (req.url).path; 345 var path = (req.url).path;
350 var pathOffset = 0; 346 var pathOffset = 0;
351 var index; 347 var index;
352 var subPart; 348 var subPart;
353 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 349 unittest.expect(
350 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
354 pathOffset += 1; 351 pathOffset += 1;
355 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ als("v1alpha/")); 352 unittest.expect(path.substring(pathOffset, pathOffset + 8),
353 unittest.equals("v1alpha/"));
356 pathOffset += 8; 354 pathOffset += 8;
357 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation; 355 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
358 356
359 var query = (req.url).query; 357 var query = (req.url).query;
360 var queryOffset = 0; 358 var queryOffset = 0;
361 var queryMap = {}; 359 var queryMap = {};
362 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 360 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
363 parseBool(n) { 361 parseBool(n) {
364 if (n == "true") return true; 362 if (n == "true") return true;
365 if (n == "false") return false; 363 if (n == "false") return false;
366 if (n == null) return null; 364 if (n == null) return null;
367 throw new core.ArgumentError("Invalid boolean: $n"); 365 throw new core.ArgumentError("Invalid boolean: $n");
368 } 366 }
367
369 if (query.length > 0) { 368 if (query.length > 0) {
370 for (var part in query.split("&")) { 369 for (var part in query.split("&")) {
371 var keyvalue = part.split("="); 370 var keyvalue = part.split("=");
372 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 371 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
372 core.Uri.decodeQueryComponent(keyvalue[1]));
373 } 373 }
374 } 374 }
375 375
376
377 var h = { 376 var h = {
378 "content-type" : "application/json; charset=utf-8", 377 "content-type": "application/json; charset=utf-8",
379 }; 378 };
380 var resp = convert.JSON.encode(buildEmpty()); 379 var resp = convert.JSON.encode(buildEmpty());
381 return new async.Future.value(stringResponse(200, h, resp)); 380 return new async.Future.value(stringResponse(200, h, resp));
382 }), true); 381 }), true);
383 res.delete(arg_name).then(unittest.expectAsync1(((api.Empty response) { 382 res.delete(arg_name).then(unittest.expectAsync1(((api.Empty response) {
384 checkEmpty(response); 383 checkEmpty(response);
385 }))); 384 })));
386 }); 385 });
387 386
388 unittest.test("method--get", () { 387 unittest.test("method--get", () {
389
390 var mock = new HttpServerMock(); 388 var mock = new HttpServerMock();
391 api.UsersSshPublicKeysResourceApi res = new api.OsloginApi(mock).users.ssh PublicKeys; 389 api.UsersSshPublicKeysResourceApi res =
390 new api.OsloginApi(mock).users.sshPublicKeys;
392 var arg_name = "foo"; 391 var arg_name = "foo";
393 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 392 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
394 var path = (req.url).path; 393 var path = (req.url).path;
395 var pathOffset = 0; 394 var pathOffset = 0;
396 var index; 395 var index;
397 var subPart; 396 var subPart;
398 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 397 unittest.expect(
398 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
399 pathOffset += 1; 399 pathOffset += 1;
400 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ als("v1alpha/")); 400 unittest.expect(path.substring(pathOffset, pathOffset + 8),
401 unittest.equals("v1alpha/"));
401 pathOffset += 8; 402 pathOffset += 8;
402 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation; 403 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
403 404
404 var query = (req.url).query; 405 var query = (req.url).query;
405 var queryOffset = 0; 406 var queryOffset = 0;
406 var queryMap = {}; 407 var queryMap = {};
407 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 408 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
408 parseBool(n) { 409 parseBool(n) {
409 if (n == "true") return true; 410 if (n == "true") return true;
410 if (n == "false") return false; 411 if (n == "false") return false;
411 if (n == null) return null; 412 if (n == null) return null;
412 throw new core.ArgumentError("Invalid boolean: $n"); 413 throw new core.ArgumentError("Invalid boolean: $n");
413 } 414 }
415
414 if (query.length > 0) { 416 if (query.length > 0) {
415 for (var part in query.split("&")) { 417 for (var part in query.split("&")) {
416 var keyvalue = part.split("="); 418 var keyvalue = part.split("=");
417 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 419 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
420 core.Uri.decodeQueryComponent(keyvalue[1]));
418 } 421 }
419 } 422 }
420 423
421
422 var h = { 424 var h = {
423 "content-type" : "application/json; charset=utf-8", 425 "content-type": "application/json; charset=utf-8",
424 }; 426 };
425 var resp = convert.JSON.encode(buildSshPublicKey()); 427 var resp = convert.JSON.encode(buildSshPublicKey());
426 return new async.Future.value(stringResponse(200, h, resp)); 428 return new async.Future.value(stringResponse(200, h, resp));
427 }), true); 429 }), true);
428 res.get(arg_name).then(unittest.expectAsync1(((api.SshPublicKey response) { 430 res
431 .get(arg_name)
432 .then(unittest.expectAsync1(((api.SshPublicKey response) {
429 checkSshPublicKey(response); 433 checkSshPublicKey(response);
430 }))); 434 })));
431 }); 435 });
432 436
433 unittest.test("method--patch", () { 437 unittest.test("method--patch", () {
434
435 var mock = new HttpServerMock(); 438 var mock = new HttpServerMock();
436 api.UsersSshPublicKeysResourceApi res = new api.OsloginApi(mock).users.ssh PublicKeys; 439 api.UsersSshPublicKeysResourceApi res =
440 new api.OsloginApi(mock).users.sshPublicKeys;
437 var arg_request = buildSshPublicKey(); 441 var arg_request = buildSshPublicKey();
438 var arg_name = "foo"; 442 var arg_name = "foo";
439 var arg_updateMask = "foo"; 443 var arg_updateMask = "foo";
440 mock.register(unittest.expectAsync2((http.BaseRequest req, json) { 444 mock.register(unittest.expectAsync2((http.BaseRequest req, json) {
441 var obj = new api.SshPublicKey.fromJson(json); 445 var obj = new api.SshPublicKey.fromJson(json);
442 checkSshPublicKey(obj); 446 checkSshPublicKey(obj);
443 447
444 var path = (req.url).path; 448 var path = (req.url).path;
445 var pathOffset = 0; 449 var pathOffset = 0;
446 var index; 450 var index;
447 var subPart; 451 var subPart;
448 unittest.expect(path.substring(pathOffset, pathOffset + 1), unittest.equ als("/")); 452 unittest.expect(
453 path.substring(pathOffset, pathOffset + 1), unittest.equals("/"));
449 pathOffset += 1; 454 pathOffset += 1;
450 unittest.expect(path.substring(pathOffset, pathOffset + 8), unittest.equ als("v1alpha/")); 455 unittest.expect(path.substring(pathOffset, pathOffset + 8),
456 unittest.equals("v1alpha/"));
451 pathOffset += 8; 457 pathOffset += 8;
452 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation; 458 // NOTE: We cannot test reserved expansions due to the inability to reve rse the operation;
453 459
454 var query = (req.url).query; 460 var query = (req.url).query;
455 var queryOffset = 0; 461 var queryOffset = 0;
456 var queryMap = {}; 462 var queryMap = {};
457 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); 463 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v);
458 parseBool(n) { 464 parseBool(n) {
459 if (n == "true") return true; 465 if (n == "true") return true;
460 if (n == "false") return false; 466 if (n == "false") return false;
461 if (n == null) return null; 467 if (n == null) return null;
462 throw new core.ArgumentError("Invalid boolean: $n"); 468 throw new core.ArgumentError("Invalid boolean: $n");
463 } 469 }
470
464 if (query.length > 0) { 471 if (query.length > 0) {
465 for (var part in query.split("&")) { 472 for (var part in query.split("&")) {
466 var keyvalue = part.split("="); 473 var keyvalue = part.split("=");
467 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d ecodeQueryComponent(keyvalue[1])); 474 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]),
475 core.Uri.decodeQueryComponent(keyvalue[1]));
468 } 476 }
469 } 477 }
470 unittest.expect(queryMap["updateMask"].first, unittest.equals(arg_update Mask)); 478 unittest.expect(
471 479 queryMap["updateMask"].first, unittest.equals(arg_updateMask));
472 480
473 var h = { 481 var h = {
474 "content-type" : "application/json; charset=utf-8", 482 "content-type": "application/json; charset=utf-8",
475 }; 483 };
476 var resp = convert.JSON.encode(buildSshPublicKey()); 484 var resp = convert.JSON.encode(buildSshPublicKey());
477 return new async.Future.value(stringResponse(200, h, resp)); 485 return new async.Future.value(stringResponse(200, h, resp));
478 }), true); 486 }), true);
479 res.patch(arg_request, arg_name, updateMask: arg_updateMask).then(unittest .expectAsync1(((api.SshPublicKey response) { 487 res
488 .patch(arg_request, arg_name, updateMask: arg_updateMask)
489 .then(unittest.expectAsync1(((api.SshPublicKey response) {
480 checkSshPublicKey(response); 490 checkSshPublicKey(response);
481 }))); 491 })));
482 }); 492 });
483
484 }); 493 });
485
486
487 } 494 }
488
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698