Skip to content

Commit 51398b7

Browse files
committed
constraints type check
1 parent e312145 commit 51398b7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/unit/experimental/components/test_schema.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ def test_schema_constraint_validation_property_not_in_node_type() -> None:
245245
assert "on node type 'Person'" in str(exc_info.value)
246246

247247

248-
def test_schema_constraint_with_additional_properties_allows_unknown_property() -> None:
248+
def test_schema_constraint_with_additional_properties_with_allows_unknown_property() -> (
249+
None
250+
):
249251
# if additional_properties is True, we can define constraints that are not in the node_type
250252
schema_dict: dict[str, Any] = {
251253
"node_types": [
@@ -260,11 +262,11 @@ def test_schema_constraint_with_additional_properties_allows_unknown_property()
260262
],
261263
}
262264

263-
# Should NOT raise - email is allowed because additional_properties=True
264-
schema = GraphSchema.model_validate(schema_dict)
265+
# Should raise - email is not allowed because the property is not defined in the node
266+
with pytest.raises(SchemaValidationError) as exc_info:
267+
GraphSchema.model_validate(schema_dict)
265268

266-
assert len(schema.constraints) == 1
267-
assert schema.constraints[0].property_name == "email"
269+
assert "Constraint references undefined property 'email'" in str(exc_info.value)
268270

269271

270272
def test_schema_with_valid_constraints() -> None:

0 commit comments

Comments
 (0)