Skip to content

Commit 50cd07a

Browse files
dmealingclaude
andcommitted
test(codegen-python): prove non-string (int) scalar-array extraction — cross-port parity
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent aa7fc17 commit 50cd07a

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

server/python/tests/codegen/test_extractor_generator.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ def _order_root() -> MetaRoot:
104104
fc.FIELD_SUBTYPE_STRING,
105105
**{fc.FIELD_ATTR_REQUIRED: True, KEY_IS_ARRAY: True},
106106
),
107+
_field(
108+
"scores",
109+
fc.FIELD_SUBTYPE_INT,
110+
**{fc.FIELD_ATTR_REQUIRED: True, KEY_IS_ARRAY: True},
111+
),
107112
_field("note", fc.FIELD_SUBTYPE_STRING), # optional scalar
108113
_field(
109114
"ship_to",
@@ -231,7 +236,8 @@ def test_extract_recovers_dirty_into_strict_payload(tmp_path, monkeypatch) -> No
231236
"Sure, here you go!\n```json\n"
232237
'{ "customer": {"name": "Ada"}, '
233238
'"lines": [{"sku":"A","qty":2},{"sku":"B","qty":1}], '
234-
'"tags": ["x","y"] }\n```'
239+
'"tags": ["x","y"], '
240+
'"scores": [3, 7] }\n```'
235241
)
236242
order = ex.extract_order_out(root, dirty)
237243
# nested single populated + typed.
@@ -242,6 +248,9 @@ def test_extract_recovers_dirty_into_strict_payload(tmp_path, monkeypatch) -> No
242248
assert order.lines[1].qty == 1
243249
# scalar array → list[str], no None elements.
244250
assert order.tags == ["x", "y"]
251+
# NON-string scalar array → list[int], coerced per-kind (cross-port parity).
252+
assert order.scores == [3, 7]
253+
assert all(isinstance(s, int) for s in order.scores)
245254
# optional nested absent → None.
246255
assert order.ship_to is None
247256

@@ -272,6 +281,7 @@ def test_recover_reexposed_never_raises_and_no_lost_required(tmp_path, monkeypat
272281
"customer": {"name": "Ada"},
273282
"lines": [{"sku": "A", "qty": 2}],
274283
"tags": ["x"],
284+
"scores": [3, 7],
275285
}
276286
)
277287
r = ex.recover_order_out(root, clean)

0 commit comments

Comments
 (0)