Compare commits
2 Commits
9849ae5c14
...
fe7bf4ef07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe7bf4ef07 | ||
|
|
289151214b |
@@ -86,7 +86,7 @@ jobs:
|
||||
# the generator's geometry. The provider suites use a fake transport: they
|
||||
# prove the documented contract, not the integration.
|
||||
- name: Print-file geometry and provider adapters
|
||||
run: $COMPOSE exec -T api python -m unittest tests.test_printfile tests.test_mercadopago tests.test_tiny tests.test_cnpj tests.test_payment_messages tests.test_jadlog tests.test_correios tests.test_quote_review tests.test_large_files tests.test_grade_check tests.test_schema tests.test_customer_document tests.test_mail_html -v
|
||||
run: $COMPOSE exec -T api python -m unittest tests.test_printfile tests.test_mercadopago tests.test_tiny tests.test_cnpj tests.test_payment_messages tests.test_jadlog tests.test_correios tests.test_quote_review tests.test_large_files tests.test_grade_check tests.test_schema tests.test_customer_document tests.test_mail_html tests.test_layout_rules -v
|
||||
|
||||
- name: Runtime and retention regressions
|
||||
run: |
|
||||
|
||||
@@ -172,6 +172,9 @@ class Item(StrictModel):
|
||||
raise ValueError('Production source does not fit the selected product')
|
||||
if is_sheet and (source.rotation_degrees or source.mirrored):
|
||||
raise ValueError('Finished sheets cannot be rotated or mirrored by the layout')
|
||||
# A textile transfer is pressed face down: mirrored, it prints backwards.
|
||||
if self.mode == 'avulsa' and source.mirrored:
|
||||
raise ValueError('Textile artwork cannot be mirrored')
|
||||
expected={(index,copy) for index,source in enumerate(self.production.sources)
|
||||
for copy in range(source.copies)}
|
||||
placed=set()
|
||||
|
||||
11
app/tiny.py
11
app/tiny.py
@@ -102,10 +102,13 @@ RECEIPT_METHODS = {'pix': 919478952, 'card': 977460722}
|
||||
PICKUP_CARRIER = 761565838
|
||||
# Dropstar's answers (2026-10-21): the store's financial category "DUPLICADO
|
||||
# DROP" (it goes in pagamento.categoria), no seller (the team links one in
|
||||
# Tiny), and the marcador KANBANDTF, added after the order is created: POST
|
||||
# /pedidos does not take marcadores.
|
||||
# Tiny), and the marcador, added after the order is created: POST /pedidos
|
||||
# does not take marcadores. Their corrections of the same day replace the
|
||||
# category and the seller with new ones (DTF SITE, SITE DTF), sent by id once
|
||||
# Dropstar creates them, and the marcador with SITE DTF: capitals, no accent,
|
||||
# no extra space, the string Kondado reads for Power BI.
|
||||
CATEGORY = 965775137
|
||||
TAG = 'KANBANDTF'
|
||||
TAG = 'SITE DTF'
|
||||
# Freight is the sender's (CIF), as on the store's orders.
|
||||
FREIGHT_PAID_BY = 'R'
|
||||
# The forma de envio each delivery service uses, by name; a Correios service
|
||||
@@ -698,7 +701,7 @@ class TinyOrders:
|
||||
return None
|
||||
|
||||
def tag(self, tiny_id, known=False):
|
||||
"""The KANBANDTF marcador on the order, once. A retry that finds the
|
||||
"""The SITE DTF marcador on the order, once. A retry that finds the
|
||||
order already created checks first, since POST adds another."""
|
||||
if known:
|
||||
have = self.request('GET', f'/pedidos/{tiny_id}/marcadores')
|
||||
|
||||
@@ -205,11 +205,11 @@ try{
|
||||
await fill('[data-q]',9);layout=await packed(9);assert.equal(layout.height,92);
|
||||
await click('[data-giro]');
|
||||
await waitFor(()=>evaluate('lastLayout?.altura===24.5 && metros===0.245'),'rotation updates packing');
|
||||
const beforeMirror=await evaluate(`$('vArea').querySelector('canvas').toDataURL()`);
|
||||
await click('[data-esp]');
|
||||
await waitFor(()=>evaluate(`$('vArea').querySelector('canvas').toDataURL()!==${JSON.stringify(beforeMirror)}`),'mirror updates pixels');
|
||||
// A textile transfer is pressed face down: mirrored, it prints backwards on
|
||||
// the garment. Textile has no mirror button (Dropstar, 2026-10-21).
|
||||
assert.equal(await evaluate(`!!document.querySelector('[data-esp]')`),false,'textile has no mirror button');
|
||||
assert.equal(await evaluate('metros'),0.245);
|
||||
await waitFor(()=>evaluate(`itemAtual?.production?.sources[0]?.mirrored===true`),'transforms in production record');
|
||||
await waitFor(()=>evaluate(`itemAtual?.production?.sources[0]?.mirrored===false`),'transforms in production record');
|
||||
assert.deepEqual(await evaluate(`({rotation:itemAtual.production.sources[0].rotation_degrees,copies:itemAtual.production.sources[0].copies})`),
|
||||
{rotation:90,copies:9});
|
||||
await waitFor(()=>evaluate(`itemAtual?.qualityStatus==='rejected'`),'low resolution refusal');
|
||||
@@ -323,6 +323,12 @@ try{
|
||||
assert.equal(await evaluate('modo'),expected);
|
||||
await fill('[data-cm]',10);await fill('[data-q]',4);await packed(4);
|
||||
}
|
||||
// UV keeps the mirror until Dropstar decides; it changes the pixels and the record.
|
||||
const beforeMirror=await evaluate(`$('vArea').querySelector('canvas').toDataURL()`);
|
||||
await click('[data-esp]');
|
||||
await waitFor(()=>evaluate(`$('vArea').querySelector('canvas').toDataURL()!==${JSON.stringify(beforeMirror)}`),'mirror updates pixels');
|
||||
await waitFor(()=>evaluate(`itemAtual?.production?.sources[0]?.mirrored===true`),'UV mirror in production record');
|
||||
await click('[data-esp]');
|
||||
// An older image load must not overwrite a newer edit, even before debounce.
|
||||
// The packing loads each artwork's image through imagemDaArte.
|
||||
await evaluate(`(()=>{window.realLoad=imagemDaArte;window.delayed=[];
|
||||
|
||||
41
tests/test_layout_rules.py
Normal file
41
tests/test_layout_rules.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""What an order's layout may carry: the layout version, and no mirrored textile."""
|
||||
import unittest
|
||||
from uuid import uuid4
|
||||
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.core.models import Item
|
||||
|
||||
|
||||
def item(mode='avulsa', mirrored=False, version=3):
|
||||
upload = uuid4()
|
||||
film = 28.5 if mode in ('uv', 'uvfile') else 57
|
||||
return {'mode': mode, 'metres': '0.21', 'grade': 100, 'uploads': [str(upload)],
|
||||
'quality_status': 'ok', 'quality_acknowledged': False,
|
||||
'production': {'version': version, 'film_width_cm': film, 'height_cm': 21,
|
||||
'sources': [{'upload_id': str(upload), 'kind': 'artwork', 'width_cm': 10,
|
||||
'length_cm': 20, 'copies': 1, 'rotation_degrees': 0,
|
||||
'mirrored': mirrored, 'measurement': 'file'}],
|
||||
'placements': [{'source_index': 0, 'copy_index': 0, 'x_cm': 0.5, 'y_cm': 0.5,
|
||||
'width_cm': 10, 'length_cm': 20, 'rotation_degrees': 0,
|
||||
'mirrored': mirrored}]}}
|
||||
|
||||
|
||||
class LayoutRulesTest(unittest.TestCase):
|
||||
def test_a_textile_transfer_is_never_mirrored(self):
|
||||
# Pressed face down, a mirrored transfer prints backwards (Dropstar, 2026-10-21).
|
||||
with self.assertRaises(ValidationError):
|
||||
Item.model_validate(item('avulsa', mirrored=True))
|
||||
Item.model_validate(item('avulsa'))
|
||||
# UV keeps the choice until Dropstar decides.
|
||||
Item.model_validate(item('uv', mirrored=True))
|
||||
|
||||
def test_layout_versions(self):
|
||||
Item.model_validate(item(version=3))
|
||||
Item.model_validate(item(version=2))
|
||||
with self.assertRaises(ValidationError):
|
||||
Item.model_validate(item(version=1))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -368,13 +368,13 @@ class TinyStatusTests(FakeTinyCase):
|
||||
|
||||
def test_the_order_is_tagged_kanbandtf_once(self):
|
||||
first = self.tiny.deliver('k1', PAID)
|
||||
self.assertEqual(first['marcador'], 'KANBANDTF')
|
||||
self.assertEqual(first['marcador'], 'SITE DTF')
|
||||
tiny_id = self.orders[0]['id']
|
||||
self.assertEqual(self.tags[tiny_id], [{'descricao': 'KANBANDTF'}])
|
||||
self.assertEqual(self.tags[tiny_id], [{'descricao': 'SITE DTF'}])
|
||||
# A second delivery finds the order and its tag, and adds nothing.
|
||||
self.tiny.deliver('k1', PAID)
|
||||
self.assertEqual(len(self.orders), 1)
|
||||
self.assertEqual(self.tags[tiny_id], [{'descricao': 'KANBANDTF'}])
|
||||
self.assertEqual(self.tags[tiny_id], [{'descricao': 'SITE DTF'}])
|
||||
|
||||
def test_a_failed_tag_is_retried_without_a_second_order(self):
|
||||
self.refuse_tag = 1
|
||||
@@ -382,9 +382,9 @@ class TinyStatusTests(FakeTinyCase):
|
||||
self.tiny.deliver('k1', PAID)
|
||||
self.assertEqual(len(self.orders), 1)
|
||||
retry = self.tiny.deliver('k1', PAID)
|
||||
self.assertEqual((retry['status'], retry['marcador']), ('already-created', 'KANBANDTF'))
|
||||
self.assertEqual((retry['status'], retry['marcador']), ('already-created', 'SITE DTF'))
|
||||
self.assertEqual(len(self.orders), 1)
|
||||
self.assertEqual(self.tags[self.orders[0]['id']], [{'descricao': 'KANBANDTF'}])
|
||||
self.assertEqual(self.tags[self.orders[0]['id']], [{'descricao': 'SITE DTF'}])
|
||||
|
||||
def test_pickup_forma_de_envio_is_found_by_name(self):
|
||||
from app.tiny import check, find_pickup
|
||||
@@ -594,7 +594,7 @@ class TinyProbeTests(FakeTinyCase):
|
||||
self.assertIn('"numeroOrdemCompra": "DTF-TESTE-', text)
|
||||
self.assertIn('Nada foi criado', text)
|
||||
self.assertIn('"categoria": {', text)
|
||||
self.assertIn('Marcador: KANBANDTF', text)
|
||||
self.assertIn('Marcador: SITE DTF', text)
|
||||
self.assertEqual(self.orders, [])
|
||||
self.assertTrue(all(method == 'GET' for method, _ in self.calls))
|
||||
|
||||
@@ -616,7 +616,7 @@ class TinyProbeTests(FakeTinyCase):
|
||||
# Then cancelled through the API, and read back: it does not stay open.
|
||||
self.assertEqual(self.orders[0]['situacao'], 2)
|
||||
self.assertIn(f"Pedido nº {self.orders[0]['numeroPedido']} cancelado no Tiny.", text)
|
||||
self.assertEqual(self.tags[self.orders[0]['id']], [{'descricao': 'KANBANDTF'}])
|
||||
self.assertEqual(self.tags[self.orders[0]['id']], [{'descricao': 'SITE DTF'}])
|
||||
|
||||
def test_cancelar_touches_only_test_orders(self):
|
||||
self.tiny.deliver('k1', PAID)
|
||||
|
||||
@@ -529,10 +529,14 @@ function pintaProgressoArte(a){
|
||||
if(!barra){ pintaArtes(); return; }
|
||||
barra.style.width=a.lendo+'%'; if(texto) texto.textContent='arquivo grande · gerando a prévia · '+faltaLeitura(a.leitura);
|
||||
}
|
||||
// O transfer têxtil é prensado com o filme virado para baixo: espelhado, sai
|
||||
// invertido na peça. Só o UV espelha, até a Dropstar decidir (21/10/2026).
|
||||
const espelhavel=()=>modo==='uv';
|
||||
function pintaArtes(){
|
||||
// A file still being read when the customer left the product page lands
|
||||
// here with no product open: nothing to paint.
|
||||
if(!MODOS[modo]) return;
|
||||
if(!espelhavel()) artes.forEach(a=>{ a.esp=false; });
|
||||
invalidaItemAtual();
|
||||
$('zona').classList.toggle('compacta', artes.length>0);
|
||||
// The same card as a finished sheet: thumbnail, size, a DPI chip, then the
|
||||
@@ -589,7 +593,7 @@ function pintaArtes(){
|
||||
'<button type="button" data-passoa="1" data-i="'+i+'" aria-label="Mais uma cópia">+</button></span></div>'+
|
||||
'<span class="giros">'+
|
||||
'<button class="gr'+(a.giro?' on':'')+'" data-giro="'+i+'" title="Girar 90°" aria-label="Girar 90°">'+icone('girar')+'</button>'+
|
||||
'<button class="gr'+(a.esp?' on':'')+'" data-esp="'+i+'" title="Espelhar" aria-label="Espelhar">'+icone('espelhar')+'</button></span>'+
|
||||
(espelhavel() ? '<button class="gr'+(a.esp?' on':'')+'" data-esp="'+i+'" title="Espelhar" aria-label="Espelhar">'+icone('espelhar')+'</button>' : '')+'</span>'+
|
||||
(sub? '<div class="conta">'+sub+'</div>' : '')+
|
||||
'<div class="atalhos">'+(TAMANHOS[larguraFilme()]||[]).map(t=>'<button class="tm'+
|
||||
(Math.abs(a.cm-t)<0.05?' on':'')+'" data-tam="'+i+'" data-t="'+t+'">'+n1(t)+' cm</button>').join('')+'</div>'+
|
||||
|
||||
Reference in New Issue
Block a user