From 94f1bfa73366ad2ea7e620c1c0cedfda75713c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Tue, 3 Nov 2026 20:57:42 -0300 Subject: [PATCH] fix: retention test reaches its file; items without a layout go to hand preparation The cleanup purges 50 expired files a pass, oldest first, and the suites before the retention test now leave more than that: the test runs it until its own fixture is reached. A print job for an item without a layout (an order written straight to the database) is hand preparation, not a crash on the footer. Co-Authored-By: Claude Opus 5.5 --- app/printjobs.py | 2 ++ tests/retention_test.py | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/printjobs.py b/app/printjobs.py index 226004f..b773bd7 100644 --- a/app/printjobs.py +++ b/app/printjobs.py @@ -176,6 +176,8 @@ def footer(job, item): def produce(storage, job, item, uploads): """Fetch the item's artwork and render it. Returns (folder, [(png path, name)], evidence); the caller removes the folder.""" + if not (item.get('production') or {}).get('placements'): + raise Unsupported('o item não tem montagem: prepare o arquivo à mão') for upload_id in item['uploads']: row = uploads.get(upload_id) if not row or row['scan_state'] != 'clean': diff --git a/tests/retention_test.py b/tests/retention_test.py index 1a8c4d0..9bd4581 100644 --- a/tests/retention_test.py +++ b/tests/retention_test.py @@ -18,7 +18,12 @@ def run(): with connect() as c: c.execute('INSERT INTO dtf_local.uploads(id,owner,name,size,object_key,multipart_id,complete,expires_at) VALUES(%s,%s,%s,%s,%s,%s,true,%s)', (uid,uuid4(),'LOCAL-RETENTION-TEST.txt',len(b'LOCAL RETENTION TEST'),key,upload,expiry)) - cleanup() + # Cleanup takes 50 at a time, oldest first: the suites before this one + # leave their own expired files ahead of the fixture. + for _ in range(100): + cleanup() + with connect() as c: + if c.execute('SELECT purged_at FROM dtf_local.uploads WHERE id=%s',(ids[0],)).fetchone()['purged_at']:break with connect() as c: assert c.execute('SELECT purged_at FROM dtf_local.uploads WHERE id=%s',(ids[0],)).fetchone()['purged_at'] assert not c.execute('SELECT purged_at FROM dtf_local.uploads WHERE id=%s',(ids[1],)).fetchone()['purged_at']