test(schema): pin offline-validation errors and AttributeKind values
Why
PR #1135 added the offline schema validator tests. Its review left two threads open (AttributeKind test, error-message assertions):
- Five tests in
tests/unit/test_schema_offline_validation.pyassertedany("<field>" in message for message in result.messages). These pass as long as some message mentions the field, so a changed message text or an extra error does not fail them. The reviewer asked for "only 1 error and it should be possible to assert more, or all, of its text". test_attribute_kind_enum_present_without_deprecated_string_memberrepeated the parametrized enum test becauseAttributeKindwas missing from its table.
Tracked as INBOX-129 in the Engineering Inbox.
What changed
Test code only. The validator and the generated models are unchanged.
test_schema_offline_validation.py:- The Jinja2, TransformPython, choice-color and relationship-cardinality tests assert the full list of messages.
test_out_of_enum_value_is_rejected_naming_field_and_valueasserts exactly one error, its field, the received value, the reason and the rendered message. For the two literal enums (relationshipkindandcardinality) the expected reason is the whole reason. For the attribute and computed-attributekinddiscriminators, it is the part that names the rejected tag. Pydantic then lists every accepted tag in the order of the generated union. That list is not pinned, so regenerating the union in a different order does not break the test.
test_schema_generated_models.py:AttributeKindis an entry of_EXPECTED_ENUM_VALUESwith its full member list, which does not includeString. The separate test is removed.
How to test
uv run pytest tests/unit/test_schema_generated_models.py tests/unit/test_schema_offline_validation.py
112 passed. Full unit suite: 3,148 passed, 2 skipped, 1 xfailed, the same as on stable. invoke format, ruff, ty, mypy, yamllint, rumdl and invoke docs-validate pass. Vale is not installed on the machine that ran the checks, so the docs style check did not run. The diff changes no documentation.
To check that the tests now detect message changes, (received: was changed to (got: in infrahub_sdk/schema/validate.py. The two modules then fail 10 tests on this branch and 2 on stable.
š¤ Generated with Claude Code