diff options
| author | Dennis Fink | 2026-11-19 21:18:37 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-19 21:18:37 +0100 |
| commit | eb11fb64e9cad6fbda2065362189653416d98577 (patch) | |
| tree | 0bc5737b1c273ea6f04adc015154565c385dc719 /tests/tasks/test_json_serializer.py | |
| parent | 88f54d9a7699944b7d56f978e724b1c0b54dde98 (diff) | |
| download | webmentions-ssg-eb11fb64e9cad6fbda2065362189653416d98577.tar.gz webmentions-ssg-eb11fb64e9cad6fbda2065362189653416d98577.zip | |
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.
Diffstat (limited to '')
| -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) |
