Files
dtf-system/tests/test_grade_rules.py
Cauê Faleiros 857eea3379
Some checks failed
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Failing after 1m17s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Has been skipped
feat: copies from the file name, the proof in the summaries, the grade off the customer's screen (Rodada 5, B3, B6, D6)
B6: "12x nome.png" enters with 12 copies, art or ready sheet (up to 200;
"1920x1080.png" is not read as copies). B3: the DPI refusal speaks per
art, the cart and payment summaries list "Prova antes de imprimir" when
chosen, and below 10 m the proof box stays, closed, saying the rule.
D6: the Ajuste Fino refusal no longer shows the grade number (Site and
server); the unused motivoNota helper is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 11:28:24 -03:00

43 lines
1.7 KiB
Python

"""Run from repository root: python3 -m unittest tests.test_grade_rules -v."""
import unittest
from app.grade_rules import triggered, treatment_message
def item(grade):
return {'grade': grade}
class GradeRulesTest(unittest.TestCase):
def test_nothing_changes_without_rules(self):
self.assertEqual(triggered({}, [item(10)], True), {})
self.assertEqual(triggered({}, [item(10)], False), {})
self.assertEqual(triggered({'aviso': 70}, [], True), {})
def test_aviso_only_and_the_worst_item(self):
self.assertEqual(triggered({'aviso': 70}, [item(69), item(90)], True), {'aviso': 69})
self.assertEqual(triggered({'aviso': 70}, [item(90)], True), {})
def test_both_rules_and_treatment_not_offered(self):
both = {'aviso': 70, 'tratamento': 50}
self.assertEqual(triggered(both, [item(45)], True), {'aviso': 45, 'tratamento': 45})
self.assertEqual(triggered(both, [item(62)], True), {'aviso': 62})
# The rule has no effect while the treatment is not offered.
self.assertEqual(triggered(both, [item(45)], False), {'aviso': 45})
self.assertEqual(triggered({'tratamento': 50}, [item(45)], False), {})
def test_the_boundary_is_exclusive(self):
self.assertEqual(triggered({'aviso': 70}, [item(70)], True), {})
self.assertEqual(triggered({'tratamento': 50}, [item(50)], True), {})
self.assertEqual(triggered({'aviso': 70}, [item(69)], True), {'aviso': 69})
def test_treatment_message(self):
self.assertEqual(
treatment_message(45),
'Sua arte está abaixo da resolução mínima, então o Ajuste Fino '
'é obrigatório neste pedido.')
if __name__ == '__main__':
unittest.main()