()
| 352 | |
| 353 | |
| 354 | def test_json_input(): |
| 355 | table = _json_table_from_list( |
| 356 | [ |
| 357 | { |
| 358 | "a": {"field": 1}, |
| 359 | "b": 2, |
| 360 | "c": 1.5, |
| 361 | "d": True, |
| 362 | "e": "foo", |
| 363 | "f": [1, 2, 3], |
| 364 | } |
| 365 | ] |
| 366 | ) |
| 367 | |
| 368 | result = table.select( |
| 369 | a=pw.this.a["field"].as_int(), |
| 370 | b=pw.this.b.as_int(), |
| 371 | c=pw.this.c.as_float(), |
| 372 | d=pw.this.d.as_bool(), |
| 373 | e=pw.this.e.as_str(), |
| 374 | f=pw.this.f[1].as_int(), |
| 375 | ) |
| 376 | |
| 377 | assert_table_equality( |
| 378 | T( |
| 379 | """ |
| 380 | | a | b | c | d | e | f |
| 381 | 1 | 1 | 2 | 1.5 | True | foo | 2 |
| 382 | """ |
| 383 | ).update_types( |
| 384 | a=Optional[int], |
| 385 | b=Optional[int], |
| 386 | c=Optional[float], |
| 387 | d=Optional[bool], |
| 388 | e=Optional[str], |
| 389 | f=Optional[int], |
| 390 | ), |
| 391 | result, |
| 392 | ) |
| 393 | |
| 394 | |
| 395 | def test_json_apply(): |
nothing calls this directly
no test coverage detected