Files
dtf-system/tests/test_prumo.py
Cauê Faleiros a712c69aca
All checks were successful
Build and deploy / Validate source (push) Successful in 11s
Build and deploy / Integration suite on a real stack (push) Successful in 5m44s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m22s
fix: align proof, treatment, metrics and site videos with PDF
2026-11-06 15:27:48 -03:00

60 lines
2.7 KiB
Python

"""The Prumo report: only what happened, in the order it happened (front 6)."""
import unittest
from datetime import datetime, timedelta, timezone
from app.prumo import customer_summary, report
class PrumoReportTests(unittest.TestCase):
def order(self):
item = {
'mode': 'avulsa', 'billed_metres': '1.30', 'metres': '1.30',
'uploads': ['u1'], 'source_dpi': 96, 'residue_accepted': 3,
'residue_accepted_at': '2026-11-05T17:32:00+00:00',
'stroke_px': 6, 'stroke_class': 'C2', 'stroke_choice': 'measured',
'production': {'height_cm': '130', 'placements': [
{'rotation_degrees': 0}, {'rotation_degrees': 90}]},
}
started = datetime(2026, 11, 5, 14, 0, tzinfo=timezone.utc)
return {'snapshot': {'items': [item]}, 'print_files': [{
'item_index': 0, 'status': 'ready', 'created_at': started, 'finished_at': started + timedelta(seconds=41),
'detail': {'format': 'png', 'dpi': 300, 'parts': [
{'from_cm': '0', 'to_cm': '15'}, {'from_cm': '15', 'to_cm': '16'}]},
}]}
def test_card_report_reads_the_decisions(self):
lines = report(self.order(), {'u1': {'name': 'arte.pdf', 'original_name': 'arte.cdr'}})
text = '\n'.join(lines)
self.assertIn('Chegou CDR, era PDF por dentro', text)
self.assertIn('PDF → PNG 300 DPI', text)
self.assertIn('Resolução detectada: 96 DPI', text)
self.assertIn('3 pontos < 2 mm — cliente aceitou', text)
self.assertIn('2 artes, 1 girada', text)
self.assertIn('Menor traço 6 px → C2', text)
self.assertIn('cliente escolheu imprimir em C1', text)
self.assertIn('2 partes (15,00 + 1,00)', text)
self.assertIn('Prumo levou 41 s', text)
def test_customer_summary_is_plain_language(self):
lines = customer_summary(self.order()['snapshot']['items'])
text = ' '.join(lines)
self.assertIn('96 DPI', text)
self.assertIn('3 pontinhos', text)
self.assertIn('C2', text)
self.assertIn('C1', text)
self.assertIn('será preparado', text)
self.assertNotIn('foi ampliada', text)
def test_unfinished_job_does_not_claim_a_conversion_or_background_check(self):
order = self.order()
order['print_files'] = [{'item_index': 0, 'status': 'manual', 'detail': {}}]
lines = report(order, {'u1': {'name': 'arte.pdf', 'original_name': 'arte.cdr'}})
text = '\n'.join(lines)
self.assertIn('Arquivo exige preparo manual', text)
self.assertNotIn('PDF → PNG', text)
self.assertNotIn('Fundo transparente', text)
if __name__ == '__main__':
unittest.main()