forked from mtusi2026/mtusi2026lab6
Implement lab6 observability with OpenTelemetry and Grafana
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
"""Offline image conversion tests inside the application image; no S3 or DB."""
|
||||
import io
|
||||
from PIL import Image
|
||||
from .image_worker import transform
|
||||
|
||||
|
||||
def main():
|
||||
source = Image.new('RGB',(320,200), (255,0,0))
|
||||
buf=io.BytesIO();source.save(buf,'PNG')
|
||||
result=transform(buf.getvalue())
|
||||
items={name:(img,fmt,mime,opts) for name,img,fmt,mime,opts in result}
|
||||
assert set(items)=={'thumbnail','crop','optimized'}
|
||||
assert items['thumbnail'][0].size==(256,160)
|
||||
assert items['crop'][0].size==(128,128)
|
||||
assert items['optimized'][0].size==(320,200)
|
||||
for name,(im,fmt,mime,opts) in items.items():
|
||||
data=io.BytesIO();im.save(data,format=fmt,**opts)
|
||||
with Image.open(io.BytesIO(data.getvalue())) as decoded:
|
||||
assert decoded.size==im.size
|
||||
assert decoded.format==fmt
|
||||
assert 'exif' not in decoded.info
|
||||
print('PASS: PNG 320x200 -> JPEG thumb 256x160, crop 128x128, optimized WebP, metadata stripped')
|
||||
|
||||
if __name__=='__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user