Skip to content

Commit

Permalink
WIP: fix schema test assumed error message
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaakola-aiven committed Oct 21, 2022
1 parent 984d794 commit 0c2b5f0
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions tests/integration/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2273,8 +2273,7 @@ async def test_invalid_namespace(registry_async_client: Client) -> None:
json_res = res.json()
assert json_res["error_code"] == 42201, json_res
expected_message = (
"Invalid AVRO schema. Error: foo-bar-baz is not a valid Avro name because it does not match the pattern "
"(?:^|\\.)[A-Za-z_][A-Za-z0-9_]*$"
"foo-bar-baz is not a valid Avro name because it does not match the pattern (?:^|\\.)[A-Za-z_][A-Za-z0-9_]*$"
)
assert json_res["message"] == expected_message, json_res

Expand Down Expand Up @@ -2883,34 +2882,28 @@ async def test_invalid_schema_should_provide_good_error_messages(registry_async_
f"subjects/{test_subject}/versions",
json={"schema": schema_str[:-1]},
)
assert res.json()["message"] == "Invalid AVRO schema. Error: Expecting ',' delimiter: line 1 column 18 (char 17)"
assert res.json()["message"] == "Expecting ',' delimiter: line 1 column 18 (char 17)"

# Unfortunately the AVRO library doesn't provide a good error message, it just raises an TypeError
schema_str = json.dumps({"type": "enum", "name": "error"})
res = await registry_async_client.post(
f"subjects/{test_subject}/versions",
json={"schema": schema_str},
)
assert (
res.json()["message"]
== "Invalid AVRO schema. Error: Enum symbols must be a sequence of strings, but it is <class 'NoneType'>"
)
assert res.json()["message"] == "Enum symbols must be a sequence of strings, but it is <class 'NoneType'>"

# This is an upstream bug in the python AVRO library, until the bug is fixed we should at least have a nice error message
schema_str = json.dumps({"type": "enum", "name": "error", "symbols": {}})
res = await registry_async_client.post(
f"subjects/{test_subject}/versions",
json={"schema": schema_str},
)
assert (
res.json()["message"]
== "Invalid AVRO schema. Error: Enum symbols must be a sequence of strings, but it is <class 'dict'>"
)
assert res.json()["message"] == "Enum symbols must be a sequence of strings, but it is <class 'dict'>"

# This is an upstream bug in the python AVRO library, until the bug is fixed we should at least have a nice error message
schema_str = json.dumps({"type": "enum", "name": "error", "symbols": ["A", "B"]})
res = await registry_async_client.post(
f"subjects/{test_subject}/versions",
json={"schema": schema_str},
)
assert res.json()["message"] == "Invalid AVRO schema. Error: error is a reserved type name."
assert res.json()["message"] == "error is a reserved type name."

0 comments on commit 0c2b5f0

Please sign in to comment.