Skip to content

Commit 4346ae0

Browse files
author
Michael Brewer
committed
test: add more assertions
1 parent 5cd0006 commit 4346ae0

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tests/functional/validator/test_validator.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,22 @@ def test_validate_base64_string_envelope(schema, wrapped_event_base64_json_strin
2525

2626
def test_validate_event_does_not_conform_with_schema(schema):
2727
data = {"message": "hello_world"}
28+
message = "data must contain ['message', 'username'] properties"
2829
with pytest.raises(
2930
exceptions.SchemaValidationError,
30-
match=re.escape(
31-
"Failed schema validation. Error: data must contain ['message', 'username'] properties, "
32-
f"Path: ['data'], Data: {data}"
33-
),
34-
):
31+
match=re.escape(f"Failed schema validation. Error: {message}, Path: ['data'], Data: {data}"),
32+
) as e:
3533
validate(event=data, schema=schema)
3634

35+
assert str(e.value) == e.value.message
36+
assert e.value.validation_message == message
37+
assert e.value.name == "data"
38+
assert e.value.path is not None
39+
assert e.value.value == data
40+
assert e.value.definition == schema
41+
assert e.value.rule == "required"
42+
assert e.value.rule_definition == schema.get("required")
43+
3744

3845
def test_validate_json_string_no_envelope(schema, wrapped_event_json_string):
3946
# WHEN data key contains a JSON String

0 commit comments

Comments
 (0)