feat: Expedição profile, stamp sizes and the Montar folha screen (front 7a.1)
The new Expedição profile and the seller may assemble sheets (capability assemble). Gestão edits the size table (letter and width). The Montar tab reads Estampas/<code>-<size>.png or <code>.png from the orders folder, checks the resolution with the Site's 96/200 DPI ruler, merges repeated lines and estimates the metres. Montar itself is slice 2. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
71
tests/stamps_test.py
Normal file
71
tests/stamps_test.py
Normal file
@@ -0,0 +1,71 @@
|
||||
"""The montador's stamp sizes: Expedição reads them and Gestão edits them.
|
||||
|
||||
Run against the local stack: python -m tests.stamps_test
|
||||
"""
|
||||
import secrets
|
||||
|
||||
from app.core import db
|
||||
from tests.smoke_test import Client
|
||||
|
||||
PASSWORD = 'senha-de-teste-123'
|
||||
|
||||
|
||||
def signed_in(email, password=PASSWORD):
|
||||
client = Client()
|
||||
client.call('/session')
|
||||
client.call('/operator/login', {'email': email, 'password': password})
|
||||
return client
|
||||
|
||||
|
||||
def run():
|
||||
tag = secrets.token_hex(3)
|
||||
su = Client()
|
||||
su.call('/session')
|
||||
assert su.call('/operator/me', operator=True)['role'] == 'superadmin'
|
||||
with db.connect() as c:
|
||||
original = c.execute('SELECT letter,width_cm FROM dtf_local.stamp_sizes ORDER BY width_cm, letter').fetchall()
|
||||
emails = {role: f'{role}-{tag}@example.test' for role in ('expedicao', 'designer', 'gestao')}
|
||||
table = [(row['letter'], float(row['width_cm'])) for row in original]
|
||||
try:
|
||||
for role, email in emails.items():
|
||||
su.call('/operator/users', {'name': role.title(), 'email': email, 'role': role,
|
||||
'password': PASSWORD}, operator=True)
|
||||
# The new profile creates through the users API and reads the table.
|
||||
shipping = signed_in(emails['expedicao'])
|
||||
me = shipping.call('/operator/me')
|
||||
assert me['role'] == 'expedicao' and me['can'] == ['assemble', 'view'], me
|
||||
read = shipping.call('/operator/stamp-sizes')['sizes']
|
||||
assert [(row['letter'], float(row['width_cm'])) for row in read] == table, read
|
||||
# The designer does not assemble: no reading the table.
|
||||
designer = signed_in(emails['designer'])
|
||||
designer.call('/operator/stamp-sizes', expected=403)
|
||||
# Gestão replaces the whole table in one go and reads it back, by width.
|
||||
manager = signed_in(emails['gestao'])
|
||||
manager.call('/operator/stamp-sizes', {'sizes': [{'letter': 'D', 'width_cm': 30},
|
||||
{'letter': 'A', 'width_cm': 20},
|
||||
{'letter': 'B', 'width_cm': 24.5}]})
|
||||
read = manager.call('/operator/stamp-sizes')['sizes']
|
||||
assert [(row['letter'], float(row['width_cm'])) for row in read] == [('A', 20), ('B', 24.5), ('D', 30)], read
|
||||
# A repeated letter and a width out of range are refused.
|
||||
manager.call('/operator/stamp-sizes', {'sizes': [{'letter': 'A', 'width_cm': 20},
|
||||
{'letter': 'A', 'width_cm': 24}]},
|
||||
expected=422)
|
||||
manager.call('/operator/stamp-sizes', {'sizes': [{'letter': 'A', 'width_cm': 0}]},
|
||||
expected=422)
|
||||
manager.call('/operator/stamp-sizes', {'sizes': [{'letter': 'A', 'width_cm': 57}]},
|
||||
expected=422)
|
||||
# Expedição only reads them; saving stays with Gestão.
|
||||
shipping.call('/operator/stamp-sizes', {'sizes': [{'letter': 'A', 'width_cm': 20}]},
|
||||
expected=403)
|
||||
read = manager.call('/operator/stamp-sizes')['sizes']
|
||||
assert [(row['letter'], float(row['width_cm'])) for row in read] == [('A', 20), ('B', 24.5), ('D', 30)], read
|
||||
print('PASS: Expedição reads the montador size table; Gestão replaces it; invalid rows are refused')
|
||||
finally:
|
||||
with db.connect() as c:
|
||||
c.execute('DELETE FROM dtf_local.stamp_sizes')
|
||||
c.cursor().executemany('INSERT INTO dtf_local.stamp_sizes(letter,width_cm) VALUES(%s,%s)', table)
|
||||
c.execute('DELETE FROM dtf_local.operators WHERE email LIKE %s', (f'%-{tag}@example.test',))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Who moves which card on the Kanban: Dropstar's flow of 2026-10-23."""
|
||||
import unittest
|
||||
|
||||
from app.core.auth import ROLES, may_move, may_reorder
|
||||
from app.core.auth import CAPABILITIES, ROLES, may_move, may_reorder
|
||||
from app.runtime import BACK, STATES, TRANSITIONS
|
||||
|
||||
|
||||
@@ -41,6 +41,17 @@ class MovesTest(unittest.TestCase):
|
||||
self.assertTrue(may_move('gestao', 'fin', 'rev', back=True))
|
||||
self.assertFalse(may_move('vendedor', 'tra', 'rec', back=True))
|
||||
|
||||
def test_expedicao_moves_nothing(self):
|
||||
# The new shipping profile assembles sheets (Fase 2, front 7) and reads
|
||||
# the board; it moves no card and orders no column.
|
||||
self.assertIn('expedicao', ROLES)
|
||||
self.assertEqual(moves('expedicao'), set())
|
||||
self.assertEqual([s for s in STATES if may_reorder('expedicao', s)], [])
|
||||
|
||||
def test_the_montador_is_open_to_exactly_five_profiles(self):
|
||||
self.assertEqual(CAPABILITIES['assemble'],
|
||||
{'superadmin', 'admin', 'gestao', 'vendedor', 'expedicao'})
|
||||
|
||||
def test_a_column_is_ordered_by_whoever_takes_its_cards_forward(self):
|
||||
self.assertEqual([s for s in STATES if may_reorder('operador', s)], ['tra', 'imp'])
|
||||
self.assertEqual([s for s in STATES if may_reorder('designer', s)], ['rec', 'cor'])
|
||||
|
||||
@@ -174,7 +174,7 @@ def run():
|
||||
seller.call(f'/operator/orders/{textil_o}/contact', {'waiting': True, 'note': 'Ligar'}, expected=403)
|
||||
# The seller only views the board (D-30): no order registered by hand either.
|
||||
# The seller only views, but answers a proof card (Dropstar, 2026-11-03).
|
||||
assert seller.call('/operator/me')['can'] == ['proof', 'view']
|
||||
assert seller.call('/operator/me')['can'] == ['assemble', 'proof', 'view']
|
||||
seller.call(f'/operator/quotes/{uv_q}/register', {'origin': 'atendimento', 'method': 'pix'}, expected=403)
|
||||
# Financeiro (Dropstar, 2026-10-30): the board, Pagamentos, Números and
|
||||
# Cotações, and cancels an order with its reason; moves nothing.
|
||||
|
||||
Reference in New Issue
Block a user