| OLD | NEW |
| (Empty) |
| 1 library googleapis.freebase.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/freebase/v1.dart' as api; | |
| 16 | |
| 17 | |
| 18 | |
| 19 core.int buildCounterReconcileCandidateNotable = 0; | |
| 20 buildReconcileCandidateNotable() { | |
| 21 var o = new api.ReconcileCandidateNotable(); | |
| 22 buildCounterReconcileCandidateNotable++; | |
| 23 if (buildCounterReconcileCandidateNotable < 3) { | |
| 24 o.id = "foo"; | |
| 25 o.name = "foo"; | |
| 26 } | |
| 27 buildCounterReconcileCandidateNotable--; | |
| 28 return o; | |
| 29 } | |
| 30 | |
| 31 checkReconcileCandidateNotable(api.ReconcileCandidateNotable o) { | |
| 32 buildCounterReconcileCandidateNotable++; | |
| 33 if (buildCounterReconcileCandidateNotable < 3) { | |
| 34 unittest.expect(o.id, unittest.equals('foo')); | |
| 35 unittest.expect(o.name, unittest.equals('foo')); | |
| 36 } | |
| 37 buildCounterReconcileCandidateNotable--; | |
| 38 } | |
| 39 | |
| 40 core.int buildCounterReconcileCandidate = 0; | |
| 41 buildReconcileCandidate() { | |
| 42 var o = new api.ReconcileCandidate(); | |
| 43 buildCounterReconcileCandidate++; | |
| 44 if (buildCounterReconcileCandidate < 3) { | |
| 45 o.confidence = 42.0; | |
| 46 o.lang = "foo"; | |
| 47 o.mid = "foo"; | |
| 48 o.name = "foo"; | |
| 49 o.notable = buildReconcileCandidateNotable(); | |
| 50 } | |
| 51 buildCounterReconcileCandidate--; | |
| 52 return o; | |
| 53 } | |
| 54 | |
| 55 checkReconcileCandidate(api.ReconcileCandidate o) { | |
| 56 buildCounterReconcileCandidate++; | |
| 57 if (buildCounterReconcileCandidate < 3) { | |
| 58 unittest.expect(o.confidence, unittest.equals(42.0)); | |
| 59 unittest.expect(o.lang, unittest.equals('foo')); | |
| 60 unittest.expect(o.mid, unittest.equals('foo')); | |
| 61 unittest.expect(o.name, unittest.equals('foo')); | |
| 62 checkReconcileCandidateNotable(o.notable); | |
| 63 } | |
| 64 buildCounterReconcileCandidate--; | |
| 65 } | |
| 66 | |
| 67 buildUnnamed719() { | |
| 68 var o = new core.List<api.ReconcileCandidate>(); | |
| 69 o.add(buildReconcileCandidate()); | |
| 70 o.add(buildReconcileCandidate()); | |
| 71 return o; | |
| 72 } | |
| 73 | |
| 74 checkUnnamed719(core.List<api.ReconcileCandidate> o) { | |
| 75 unittest.expect(o, unittest.hasLength(2)); | |
| 76 checkReconcileCandidate(o[0]); | |
| 77 checkReconcileCandidate(o[1]); | |
| 78 } | |
| 79 | |
| 80 core.int buildCounterReconcileGetCosts = 0; | |
| 81 buildReconcileGetCosts() { | |
| 82 var o = new api.ReconcileGetCosts(); | |
| 83 buildCounterReconcileGetCosts++; | |
| 84 if (buildCounterReconcileGetCosts < 3) { | |
| 85 o.hits = 42; | |
| 86 o.ms = 42; | |
| 87 } | |
| 88 buildCounterReconcileGetCosts--; | |
| 89 return o; | |
| 90 } | |
| 91 | |
| 92 checkReconcileGetCosts(api.ReconcileGetCosts o) { | |
| 93 buildCounterReconcileGetCosts++; | |
| 94 if (buildCounterReconcileGetCosts < 3) { | |
| 95 unittest.expect(o.hits, unittest.equals(42)); | |
| 96 unittest.expect(o.ms, unittest.equals(42)); | |
| 97 } | |
| 98 buildCounterReconcileGetCosts--; | |
| 99 } | |
| 100 | |
| 101 core.int buildCounterReconcileGetWarning = 0; | |
| 102 buildReconcileGetWarning() { | |
| 103 var o = new api.ReconcileGetWarning(); | |
| 104 buildCounterReconcileGetWarning++; | |
| 105 if (buildCounterReconcileGetWarning < 3) { | |
| 106 o.location = "foo"; | |
| 107 o.message = "foo"; | |
| 108 o.reason = "foo"; | |
| 109 } | |
| 110 buildCounterReconcileGetWarning--; | |
| 111 return o; | |
| 112 } | |
| 113 | |
| 114 checkReconcileGetWarning(api.ReconcileGetWarning o) { | |
| 115 buildCounterReconcileGetWarning++; | |
| 116 if (buildCounterReconcileGetWarning < 3) { | |
| 117 unittest.expect(o.location, unittest.equals('foo')); | |
| 118 unittest.expect(o.message, unittest.equals('foo')); | |
| 119 unittest.expect(o.reason, unittest.equals('foo')); | |
| 120 } | |
| 121 buildCounterReconcileGetWarning--; | |
| 122 } | |
| 123 | |
| 124 buildUnnamed720() { | |
| 125 var o = new core.List<api.ReconcileGetWarning>(); | |
| 126 o.add(buildReconcileGetWarning()); | |
| 127 o.add(buildReconcileGetWarning()); | |
| 128 return o; | |
| 129 } | |
| 130 | |
| 131 checkUnnamed720(core.List<api.ReconcileGetWarning> o) { | |
| 132 unittest.expect(o, unittest.hasLength(2)); | |
| 133 checkReconcileGetWarning(o[0]); | |
| 134 checkReconcileGetWarning(o[1]); | |
| 135 } | |
| 136 | |
| 137 core.int buildCounterReconcileGet = 0; | |
| 138 buildReconcileGet() { | |
| 139 var o = new api.ReconcileGet(); | |
| 140 buildCounterReconcileGet++; | |
| 141 if (buildCounterReconcileGet < 3) { | |
| 142 o.candidate = buildUnnamed719(); | |
| 143 o.costs = buildReconcileGetCosts(); | |
| 144 o.match = buildReconcileCandidate(); | |
| 145 o.warning = buildUnnamed720(); | |
| 146 } | |
| 147 buildCounterReconcileGet--; | |
| 148 return o; | |
| 149 } | |
| 150 | |
| 151 checkReconcileGet(api.ReconcileGet o) { | |
| 152 buildCounterReconcileGet++; | |
| 153 if (buildCounterReconcileGet < 3) { | |
| 154 checkUnnamed719(o.candidate); | |
| 155 checkReconcileGetCosts(o.costs); | |
| 156 checkReconcileCandidate(o.match); | |
| 157 checkUnnamed720(o.warning); | |
| 158 } | |
| 159 buildCounterReconcileGet--; | |
| 160 } | |
| 161 | |
| 162 buildUnnamed721() { | |
| 163 var o = new core.List<core.String>(); | |
| 164 o.add("foo"); | |
| 165 o.add("foo"); | |
| 166 return o; | |
| 167 } | |
| 168 | |
| 169 checkUnnamed721(core.List<core.String> o) { | |
| 170 unittest.expect(o, unittest.hasLength(2)); | |
| 171 unittest.expect(o[0], unittest.equals('foo')); | |
| 172 unittest.expect(o[1], unittest.equals('foo')); | |
| 173 } | |
| 174 | |
| 175 buildUnnamed722() { | |
| 176 var o = new core.List<core.String>(); | |
| 177 o.add("foo"); | |
| 178 o.add("foo"); | |
| 179 return o; | |
| 180 } | |
| 181 | |
| 182 checkUnnamed722(core.List<core.String> o) { | |
| 183 unittest.expect(o, unittest.hasLength(2)); | |
| 184 unittest.expect(o[0], unittest.equals('foo')); | |
| 185 unittest.expect(o[1], unittest.equals('foo')); | |
| 186 } | |
| 187 | |
| 188 buildUnnamed723() { | |
| 189 var o = new core.List<core.String>(); | |
| 190 o.add("foo"); | |
| 191 o.add("foo"); | |
| 192 return o; | |
| 193 } | |
| 194 | |
| 195 checkUnnamed723(core.List<core.String> o) { | |
| 196 unittest.expect(o, unittest.hasLength(2)); | |
| 197 unittest.expect(o[0], unittest.equals('foo')); | |
| 198 unittest.expect(o[1], unittest.equals('foo')); | |
| 199 } | |
| 200 | |
| 201 buildUnnamed724() { | |
| 202 var o = new core.List<core.String>(); | |
| 203 o.add("foo"); | |
| 204 o.add("foo"); | |
| 205 return o; | |
| 206 } | |
| 207 | |
| 208 checkUnnamed724(core.List<core.String> o) { | |
| 209 unittest.expect(o, unittest.hasLength(2)); | |
| 210 unittest.expect(o[0], unittest.equals('foo')); | |
| 211 unittest.expect(o[1], unittest.equals('foo')); | |
| 212 } | |
| 213 | |
| 214 buildUnnamed725() { | |
| 215 var o = new core.List<core.String>(); | |
| 216 o.add("foo"); | |
| 217 o.add("foo"); | |
| 218 return o; | |
| 219 } | |
| 220 | |
| 221 checkUnnamed725(core.List<core.String> o) { | |
| 222 unittest.expect(o, unittest.hasLength(2)); | |
| 223 unittest.expect(o[0], unittest.equals('foo')); | |
| 224 unittest.expect(o[1], unittest.equals('foo')); | |
| 225 } | |
| 226 | |
| 227 buildUnnamed726() { | |
| 228 var o = new core.List<core.String>(); | |
| 229 o.add("foo"); | |
| 230 o.add("foo"); | |
| 231 return o; | |
| 232 } | |
| 233 | |
| 234 checkUnnamed726(core.List<core.String> o) { | |
| 235 unittest.expect(o, unittest.hasLength(2)); | |
| 236 unittest.expect(o[0], unittest.equals('foo')); | |
| 237 unittest.expect(o[1], unittest.equals('foo')); | |
| 238 } | |
| 239 | |
| 240 buildUnnamed727() { | |
| 241 var o = new core.List<core.String>(); | |
| 242 o.add("foo"); | |
| 243 o.add("foo"); | |
| 244 return o; | |
| 245 } | |
| 246 | |
| 247 checkUnnamed727(core.List<core.String> o) { | |
| 248 unittest.expect(o, unittest.hasLength(2)); | |
| 249 unittest.expect(o[0], unittest.equals('foo')); | |
| 250 unittest.expect(o[1], unittest.equals('foo')); | |
| 251 } | |
| 252 | |
| 253 buildUnnamed728() { | |
| 254 var o = new core.List<core.String>(); | |
| 255 o.add("foo"); | |
| 256 o.add("foo"); | |
| 257 return o; | |
| 258 } | |
| 259 | |
| 260 checkUnnamed728(core.List<core.String> o) { | |
| 261 unittest.expect(o, unittest.hasLength(2)); | |
| 262 unittest.expect(o[0], unittest.equals('foo')); | |
| 263 unittest.expect(o[1], unittest.equals('foo')); | |
| 264 } | |
| 265 | |
| 266 buildUnnamed729() { | |
| 267 var o = new core.List<core.String>(); | |
| 268 o.add("foo"); | |
| 269 o.add("foo"); | |
| 270 return o; | |
| 271 } | |
| 272 | |
| 273 checkUnnamed729(core.List<core.String> o) { | |
| 274 unittest.expect(o, unittest.hasLength(2)); | |
| 275 unittest.expect(o[0], unittest.equals('foo')); | |
| 276 unittest.expect(o[1], unittest.equals('foo')); | |
| 277 } | |
| 278 | |
| 279 buildUnnamed730() { | |
| 280 var o = new core.List<core.String>(); | |
| 281 o.add("foo"); | |
| 282 o.add("foo"); | |
| 283 return o; | |
| 284 } | |
| 285 | |
| 286 checkUnnamed730(core.List<core.String> o) { | |
| 287 unittest.expect(o, unittest.hasLength(2)); | |
| 288 unittest.expect(o[0], unittest.equals('foo')); | |
| 289 unittest.expect(o[1], unittest.equals('foo')); | |
| 290 } | |
| 291 | |
| 292 | |
| 293 main() { | |
| 294 unittest.group("obj-schema-ReconcileCandidateNotable", () { | |
| 295 unittest.test("to-json--from-json", () { | |
| 296 var o = buildReconcileCandidateNotable(); | |
| 297 var od = new api.ReconcileCandidateNotable.fromJson(o.toJson()); | |
| 298 checkReconcileCandidateNotable(od); | |
| 299 }); | |
| 300 }); | |
| 301 | |
| 302 | |
| 303 unittest.group("obj-schema-ReconcileCandidate", () { | |
| 304 unittest.test("to-json--from-json", () { | |
| 305 var o = buildReconcileCandidate(); | |
| 306 var od = new api.ReconcileCandidate.fromJson(o.toJson()); | |
| 307 checkReconcileCandidate(od); | |
| 308 }); | |
| 309 }); | |
| 310 | |
| 311 | |
| 312 unittest.group("obj-schema-ReconcileGetCosts", () { | |
| 313 unittest.test("to-json--from-json", () { | |
| 314 var o = buildReconcileGetCosts(); | |
| 315 var od = new api.ReconcileGetCosts.fromJson(o.toJson()); | |
| 316 checkReconcileGetCosts(od); | |
| 317 }); | |
| 318 }); | |
| 319 | |
| 320 | |
| 321 unittest.group("obj-schema-ReconcileGetWarning", () { | |
| 322 unittest.test("to-json--from-json", () { | |
| 323 var o = buildReconcileGetWarning(); | |
| 324 var od = new api.ReconcileGetWarning.fromJson(o.toJson()); | |
| 325 checkReconcileGetWarning(od); | |
| 326 }); | |
| 327 }); | |
| 328 | |
| 329 | |
| 330 unittest.group("obj-schema-ReconcileGet", () { | |
| 331 unittest.test("to-json--from-json", () { | |
| 332 var o = buildReconcileGet(); | |
| 333 var od = new api.ReconcileGet.fromJson(o.toJson()); | |
| 334 checkReconcileGet(od); | |
| 335 }); | |
| 336 }); | |
| 337 | |
| 338 | |
| 339 unittest.group("resource-FreebaseApi", () { | |
| 340 unittest.test("method--reconcile", () { | |
| 341 | |
| 342 var mock = new common_test.HttpServerMock(); | |
| 343 api.FreebaseApi res = new api.FreebaseApi(mock); | |
| 344 var arg_confidence = 42.0; | |
| 345 var arg_kind = buildUnnamed721(); | |
| 346 var arg_lang = buildUnnamed722(); | |
| 347 var arg_limit = 42; | |
| 348 var arg_name = "foo"; | |
| 349 var arg_prop = buildUnnamed723(); | |
| 350 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
| 351 var path = (req.url).path; | |
| 352 var pathOffset = 0; | |
| 353 var index; | |
| 354 var subPart; | |
| 355 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("/freebase/v1/")); | |
| 356 pathOffset += 13; | |
| 357 unittest.expect(path.substring(pathOffset, pathOffset + 9), unittest.equ
als("reconcile")); | |
| 358 pathOffset += 9; | |
| 359 | |
| 360 var query = (req.url).query; | |
| 361 var queryOffset = 0; | |
| 362 var queryMap = {}; | |
| 363 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
| 364 parseBool(n) { | |
| 365 if (n == "true") return true; | |
| 366 if (n == "false") return false; | |
| 367 if (n == null) return null; | |
| 368 throw new core.ArgumentError("Invalid boolean: $n"); | |
| 369 } | |
| 370 if (query.length > 0) { | |
| 371 for (var part in query.split("&")) { | |
| 372 var keyvalue = part.split("="); | |
| 373 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
| 374 } | |
| 375 } | |
| 376 unittest.expect(core.num.parse(queryMap["confidence"].first), unittest.e
quals(arg_confidence)); | |
| 377 unittest.expect(queryMap["kind"], unittest.equals(arg_kind)); | |
| 378 unittest.expect(queryMap["lang"], unittest.equals(arg_lang)); | |
| 379 unittest.expect(core.int.parse(queryMap["limit"].first), unittest.equals
(arg_limit)); | |
| 380 unittest.expect(queryMap["name"].first, unittest.equals(arg_name)); | |
| 381 unittest.expect(queryMap["prop"], unittest.equals(arg_prop)); | |
| 382 | |
| 383 | |
| 384 var h = { | |
| 385 "content-type" : "application/json; charset=utf-8", | |
| 386 }; | |
| 387 var resp = convert.JSON.encode(buildReconcileGet()); | |
| 388 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
| 389 }), true); | |
| 390 res.reconcile(confidence: arg_confidence, kind: arg_kind, lang: arg_lang,
limit: arg_limit, name: arg_name, prop: arg_prop).then(unittest.expectAsync(((ap
i.ReconcileGet response) { | |
| 391 checkReconcileGet(response); | |
| 392 }))); | |
| 393 }); | |
| 394 | |
| 395 unittest.test("method--search", () { | |
| 396 // TODO: Implement tests for media upload; | |
| 397 // TODO: Implement tests for media download; | |
| 398 | |
| 399 var mock = new common_test.HttpServerMock(); | |
| 400 api.FreebaseApi res = new api.FreebaseApi(mock); | |
| 401 var arg_asOfTime = "foo"; | |
| 402 var arg_callback = "foo"; | |
| 403 var arg_cursor = 42; | |
| 404 var arg_domain = buildUnnamed724(); | |
| 405 var arg_encode = "foo"; | |
| 406 var arg_exact = true; | |
| 407 var arg_filter = buildUnnamed725(); | |
| 408 var arg_format = "foo"; | |
| 409 var arg_help = "foo"; | |
| 410 var arg_indent = true; | |
| 411 var arg_lang = buildUnnamed726(); | |
| 412 var arg_limit = 42; | |
| 413 var arg_mid = buildUnnamed727(); | |
| 414 var arg_mqlOutput = "foo"; | |
| 415 var arg_output = "foo"; | |
| 416 var arg_prefixed = true; | |
| 417 var arg_query = "foo"; | |
| 418 var arg_scoring = "foo"; | |
| 419 var arg_spell = "foo"; | |
| 420 var arg_stemmed = true; | |
| 421 var arg_type = buildUnnamed728(); | |
| 422 var arg_with_ = buildUnnamed729(); | |
| 423 var arg_without = buildUnnamed730(); | |
| 424 mock.register(unittest.expectAsync((http.BaseRequest req, json) { | |
| 425 var path = (req.url).path; | |
| 426 var pathOffset = 0; | |
| 427 var index; | |
| 428 var subPart; | |
| 429 unittest.expect(path.substring(pathOffset, pathOffset + 13), unittest.eq
uals("/freebase/v1/")); | |
| 430 pathOffset += 13; | |
| 431 unittest.expect(path.substring(pathOffset, pathOffset + 6), unittest.equ
als("search")); | |
| 432 pathOffset += 6; | |
| 433 | |
| 434 var query = (req.url).query; | |
| 435 var queryOffset = 0; | |
| 436 var queryMap = {}; | |
| 437 addQueryParam(n, v) => queryMap.putIfAbsent(n, () => []).add(v); | |
| 438 parseBool(n) { | |
| 439 if (n == "true") return true; | |
| 440 if (n == "false") return false; | |
| 441 if (n == null) return null; | |
| 442 throw new core.ArgumentError("Invalid boolean: $n"); | |
| 443 } | |
| 444 if (query.length > 0) { | |
| 445 for (var part in query.split("&")) { | |
| 446 var keyvalue = part.split("="); | |
| 447 addQueryParam(core.Uri.decodeQueryComponent(keyvalue[0]), core.Uri.d
ecodeQueryComponent(keyvalue[1])); | |
| 448 } | |
| 449 } | |
| 450 unittest.expect(queryMap["as_of_time"].first, unittest.equals(arg_asOfTi
me)); | |
| 451 unittest.expect(queryMap["callback"].first, unittest.equals(arg_callback
)); | |
| 452 unittest.expect(core.int.parse(queryMap["cursor"].first), unittest.equal
s(arg_cursor)); | |
| 453 unittest.expect(queryMap["domain"], unittest.equals(arg_domain)); | |
| 454 unittest.expect(queryMap["encode"].first, unittest.equals(arg_encode)); | |
| 455 unittest.expect(queryMap["exact"].first, unittest.equals("$arg_exact")); | |
| 456 unittest.expect(queryMap["filter"], unittest.equals(arg_filter)); | |
| 457 unittest.expect(queryMap["format"].first, unittest.equals(arg_format)); | |
| 458 unittest.expect(queryMap["help"].first, unittest.equals(arg_help)); | |
| 459 unittest.expect(queryMap["indent"].first, unittest.equals("$arg_indent")
); | |
| 460 unittest.expect(queryMap["lang"], unittest.equals(arg_lang)); | |
| 461 unittest.expect(core.int.parse(queryMap["limit"].first), unittest.equals
(arg_limit)); | |
| 462 unittest.expect(queryMap["mid"], unittest.equals(arg_mid)); | |
| 463 unittest.expect(queryMap["mql_output"].first, unittest.equals(arg_mqlOut
put)); | |
| 464 unittest.expect(queryMap["output"].first, unittest.equals(arg_output)); | |
| 465 unittest.expect(queryMap["prefixed"].first, unittest.equals("$arg_prefix
ed")); | |
| 466 unittest.expect(queryMap["query"].first, unittest.equals(arg_query)); | |
| 467 unittest.expect(queryMap["scoring"].first, unittest.equals(arg_scoring))
; | |
| 468 unittest.expect(queryMap["spell"].first, unittest.equals(arg_spell)); | |
| 469 unittest.expect(queryMap["stemmed"].first, unittest.equals("$arg_stemmed
")); | |
| 470 unittest.expect(queryMap["type"], unittest.equals(arg_type)); | |
| 471 unittest.expect(queryMap["with"], unittest.equals(arg_with_)); | |
| 472 unittest.expect(queryMap["without"], unittest.equals(arg_without)); | |
| 473 | |
| 474 | |
| 475 var h = { | |
| 476 "content-type" : "application/json; charset=utf-8", | |
| 477 }; | |
| 478 var resp = ""; | |
| 479 return new async.Future.value(common_test.stringResponse(200, h, resp)); | |
| 480 }), true); | |
| 481 res.search(asOfTime: arg_asOfTime, callback: arg_callback, cursor: arg_cur
sor, domain: arg_domain, encode: arg_encode, exact: arg_exact, filter: arg_filte
r, format: arg_format, help: arg_help, indent: arg_indent, lang: arg_lang, limit
: arg_limit, mid: arg_mid, mqlOutput: arg_mqlOutput, output: arg_output, prefixe
d: arg_prefixed, query: arg_query, scoring: arg_scoring, spell: arg_spell, stemm
ed: arg_stemmed, type: arg_type, with_: arg_with_, without: arg_without).then(un
ittest.expectAsync((_) {})); | |
| 482 }); | |
| 483 | |
| 484 }); | |
| 485 | |
| 486 | |
| 487 } | |
| 488 | |
| OLD | NEW |