From eb11fb64e9cad6fbda2065362189653416d98577 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Thu, 19 Nov 2026 21:18:37 +0100 Subject: test: expand failure and migration coverage Add regression coverage for malformed input, lost task claims, moderation races, network failures, serializer validation, and production configuration guards. Exercise migration downgrade, backfill, and autogeneration paths plus additional receiver and sender edge cases. --- tests/tasks/test_json_serializer.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tests/tasks/test_json_serializer.py') 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) -- cgit v1.3.1