diff options
Diffstat (limited to 'tests/tasks/test_json_serializer.py')
| -rw-r--r-- | tests/tasks/test_json_serializer.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/tasks/test_json_serializer.py b/tests/tasks/test_json_serializer.py index 6077ebd..32a862a 100644 --- a/tests/tasks/test_json_serializer.py +++ b/tests/tasks/test_json_serializer.py @@ -98,3 +98,30 @@ def test_compression_with_json(app: Flask) -> None: raw = huey.huey.serializer.serialize(payload) assert raw.startswith(b"\x1f\x8b") assert huey.huey.serializer.deserialize(raw) == payload + + +@pytest.mark.parametrize( + ("encoded", "expected_error", "message"), + [ + ( + b'{"type":"error","value":"not metadata"}', + TypeError, + "Invalid Huey JSON error metadata", + ), + ( + b'{"type":"dict","value":[["key",1],["key",2]]}', + ValueError, + "Duplicate Huey JSON dictionary key", + ), + ( + b'{"type":"dict","value":[["key",1],[42,2]]}', + ValueError, + "Invalid Huey JSON dictionary entry", + ), + ], +) +def test_rejects_invalid_huey_json_structure( + encoded: bytes, expected_error: type[Exception], message: str +) -> None: + with pytest.raises(expected_error, match=message): + TaggedJSONSerializer().deserialize(encoded) |
