fix: review of phase-2 stage 0 and fronts 5, 6 and 11
All checks were successful
Build and deploy / Publish images (push) Successful in 1m5s
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 5m7s
Build and deploy / Secret scan and release gate (push) Successful in 6s
All checks were successful
Build and deploy / Publish images (push) Successful in 1m5s
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 5m7s
Build and deploy / Secret scan and release gate (push) Successful in 6s
- A paid treatment adds its 24 h to Arte recebida's acceptable time, on the card and in Números (fronts 5 and 11). - TINY_PRODUCT_TREATMENT is a required Tiny setting once the treatment has a price, instead of every treated order failing at the Tiny. - A quote reads each PDF once: Files caches the header and the DPI. - A proof made from the parent's final split into parts uses the part that holds the finest stroke, not the last one (0.1). - Prumo report: one format line per item, the time from the claim (kept on the finished print file), and the stroke class in customer words. - The Site says the Prumo checks the art, and a too-tall PNG no longer says "Este PDF". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ Runs where Pillow and pikepdf are installed (the API image).
|
||||
import io
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
import pikepdf
|
||||
from PIL import Image
|
||||
@@ -26,6 +27,25 @@ class FakeFiles:
|
||||
return grade_check.pdf_dpi(handle.name)
|
||||
|
||||
|
||||
class CountingStorage:
|
||||
"""A storage that counts every read, keyed by object_key as the real one."""
|
||||
|
||||
def __init__(self, blobs):
|
||||
self.bucket = 'bucket'
|
||||
self.blobs = blobs
|
||||
self.downloads = 0
|
||||
self.heads = 0
|
||||
self.client = self
|
||||
|
||||
def get_object(self, Bucket, Key, Range=None):
|
||||
self.heads += 1
|
||||
return {'Body': io.BytesIO(self.blobs[Key][:grade_check.HEAD_BYTES])}
|
||||
|
||||
def download_fileobj(self, bucket, key, handle):
|
||||
self.downloads += 1
|
||||
handle.write(self.blobs[key])
|
||||
|
||||
|
||||
def encoded(fmt, size, **options):
|
||||
out = io.BytesIO()
|
||||
Image.new('RGBA' if fmt in ('PNG', 'WEBP') else 'RGB', size, (200, 30, 30)).save(out, fmt, **options)
|
||||
@@ -81,6 +101,19 @@ class GradeCheckTests(unittest.TestCase):
|
||||
self.assertEqual(claim(40, [('x.cdr', 57, 0)]), 'Nota não conferida no servidor')
|
||||
self.assertIsNone(claim(0, [('x.cdr', 57, 0)]))
|
||||
|
||||
def test_a_file_is_read_once_per_quote(self):
|
||||
storage = CountingStorage({'k.pdf': b'%PDF-1.4 test', 'k.png': encoded('PNG', (100, 50))})
|
||||
files = grade_check.Files(storage)
|
||||
pdf_row = {'object_key': 'k.pdf', 'size': 15, 'name': 'a.pdf'}
|
||||
with mock.patch.object(grade_check, 'pdf_dpi', return_value=300):
|
||||
self.assertEqual(files.pdf_dpi(pdf_row), 300)
|
||||
self.assertEqual(files.pdf_dpi(pdf_row), 300)
|
||||
self.assertEqual(storage.downloads, 1)
|
||||
png_row = {'object_key': 'k.png', 'size': 1, 'name': 'a.png'}
|
||||
self.assertEqual(files.head(png_row)[:8], b'\x89PNG\r\n\x1a\n')
|
||||
self.assertEqual(files.head(png_row)[:8], b'\x89PNG\r\n\x1a\n')
|
||||
self.assertEqual(storage.heads, 1)
|
||||
|
||||
def test_resolution_boundaries_and_consent(self):
|
||||
width = lambda dpi: int(dpi * 57 / 2.54) + 1
|
||||
files = FakeFiles({f'{dpi}.png': encoded('PNG', (width(dpi), 20))
|
||||
|
||||
Reference in New Issue
Block a user