test(pipeline): coordinate stale writers within the live lease window
This commit is contained in:
@@ -66,3 +66,54 @@ def test_invalid_notification_is_rejected(field, value):
|
||||
data[field] = value
|
||||
with pytest.raises((ValueError, TypeError)):
|
||||
validate_job(data)
|
||||
|
||||
|
||||
def test_worker_rejects_oversized_pixels_before_decode():
|
||||
import hashlib
|
||||
import io
|
||||
|
||||
from PIL import Image
|
||||
|
||||
from src.pipeline import PermanentFailure
|
||||
from src.worker import make_variants
|
||||
|
||||
stream = io.BytesIO()
|
||||
Image.new("1", (8000, 5001)).save(stream, format="PNG")
|
||||
raw = stream.getvalue()
|
||||
row = dict(
|
||||
size_bytes=len(raw),
|
||||
sha256=hashlib.sha256(raw).hexdigest(),
|
||||
content_type="image/png",
|
||||
pipeline_version=1,
|
||||
)
|
||||
with (
|
||||
pytest.warns(Image.DecompressionBombWarning),
|
||||
pytest.raises(PermanentFailure, match="pixel_limit"),
|
||||
):
|
||||
list(make_variants(raw, row))
|
||||
|
||||
|
||||
def test_worker_rejects_changed_source_checksum():
|
||||
from src.pipeline import PermanentFailure
|
||||
from src.worker import make_variants
|
||||
|
||||
with pytest.raises(PermanentFailure, match="source_checksum_mismatch"):
|
||||
list(make_variants(b"changed", dict(size_bytes=7, sha256="0" * 64)))
|
||||
|
||||
|
||||
def test_worker_rejects_invalid_image_as_permanent():
|
||||
import hashlib
|
||||
|
||||
from src.pipeline import PermanentFailure
|
||||
from src.worker import make_variants
|
||||
|
||||
raw = b"not an image"
|
||||
with pytest.raises(PermanentFailure, match="invalid_image"):
|
||||
list(
|
||||
make_variants(
|
||||
raw,
|
||||
dict(
|
||||
size_bytes=len(raw), sha256=hashlib.sha256(raw).hexdigest()
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user