Merge main into label

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-11 11:32:27 -03:00
39 changed files with 920 additions and 148 deletions

View File

@@ -3,22 +3,35 @@
Run against the local stack: SITE_BASE_URL=http://site SITE_HOST_HEADER=localhost
python -m tests.site_admin_test
"""
import io
import secrets
from datetime import datetime, timedelta, timezone
from uuid import uuid4
from PIL import Image, ImageDraw
from app.core import db
from tests.print_file_test import artwork
from tests.smoke_test import Client, item_spec, upload_bytes
PASSWORD = 'senha-de-teste-123'
UV = 'uv'
PREMIUM = 'premium'
def quote(client, item, mail):
def premium_sheet():
"""A 57 cm wide sheet above 96 DPI at that width, so the server accepts it."""
image = Image.new('RGBA', (2400, 800), (0, 0, 0, 0))
ImageDraw.Draw(image).rectangle([40, 40, 2360, 760], fill=(220, 30, 60, 255))
out = io.BytesIO()
image.save(out, 'PNG', dpi=(300, 300))
return out.getvalue()
def quote(client, item, mail, expected=200):
return client.call('/quotes', {'request_key': str(uuid4()),
'customer': {'cnpj': '11222333000181', 'zap': '11999999999', 'mail': mail},
'items': [item], 'freight': {'service': 'pickup'}})
'items': [item], 'freight': {'service': 'pickup'}}, expected=expected)
def run():
@@ -34,9 +47,30 @@ def run():
prices, user = [], None
try:
products = manager.call('/operator/site/products')['products']
assert {product['id'] for product in products} == {'file', 'avulsa', 'uvfile', 'uv', 'tratamento'}
assert {product['id'] for product in products} == \
{'file', 'avulsa', 'uvfile', 'uv', 'premium', 'tratamento'}
assert all(product['unit'] in ('metro', 'pedido') and product['title'] for product in products)
# Front 3: Premium is listed and starts switched off (Marcus, 2026-11-10).
premium_entry = next(product for product in products if product['id'] == PREMIUM)
assert premium_entry['enabled'] is False, premium_entry
assert premium_entry['title'] == 'Têxtil Premium · 8 passadas', premium_entry
assert client.call('/session')['products'][PREMIUM]['enabled'] is False
premium_item = {**item_spec(PREMIUM, '1', 0, upload_bytes(
client, premium_sheet(), name='LOCAL-SITE-PREMIUM.png')),
'quality_status': 'warning', 'quality_acknowledged': True}
refused = quote(client, premium_item, mail, expected=422)
assert refused['detail'] == 'Este produto não está à venda agora.', refused
manager.call(f'/operator/site/products/{PREMIUM}', {'enabled': True})
assert client.call('/session')['products'][PREMIUM]['enabled'] is True
created = quote(client, premium_item, mail)
assert created['status'] == 'approved', created
approved = client.call('/quotes/' + created['id'])['approved']
assert approved['items'][0]['mode'] == PREMIUM, approved
assert approved['items'][0]['unit_cents'] == 3990, approved
assert approved['total_cents'] == 3990, approved
manager.call(f'/operator/site/products/{PREMIUM}', {'enabled': False})
manager.call(f'/operator/site/products/{UV}', {'enabled': True})
uid = upload_bytes(client, artwork(), name='LOCAL-SITE-ADMIN.png')
item = {**item_spec('uv', '1', 0, uid), 'quality_status': 'warning', 'quality_acknowledged': True}
@@ -123,13 +157,15 @@ def run():
staff.call(f'/operator/site/products/{UV}', {'enabled': True}, expected=403)
staff.call(f'/operator/site/products/{UV}/prices', {'unit_cents': 1000}, expected=403)
staff.call(f'/operator/site/prices/{made["id"]}/cancel', {}, expected=403)
print('PASS: the Site tab switches a product off and refuses quotes, schedules and cancels prices,'
' charges the new price, and refuses a non-manage profile')
print('PASS: the Site tab switches a product off and refuses quotes, lists Premium switched off'
' and accepts it once enabled, schedules and cancels prices, charges the new price,'
' and refuses a non-manage profile')
finally:
with db.connect() as c:
if prices:
c.execute('DELETE FROM dtf_local.product_prices WHERE id=ANY(%s::bigint[])', (prices,))
c.execute("UPDATE dtf_local.products SET enabled=true WHERE id=%s", (UV,))
c.execute("UPDATE dtf_local.products SET enabled=false WHERE id=%s", (PREMIUM,))
if user:
try:
manager.call('/operator/users/' + str(user['id']) + '/delete', {}, expected=200)

View File

@@ -131,7 +131,7 @@ def item_spec(mode, metres, grade, uid):
return {'mode':mode,'metres':str(metres),'grade':grade,'uploads':[uid],
'production':{'version':2,'film_width_cm':film_width,'height_cm':length_cm,
'sources':[{'upload_id':uid,
'kind':'sheet' if mode in ('file','uvfile') else 'artwork',
'kind':'sheet' if mode in ('file','uvfile','premium') else 'artwork',
'width_cm':film_width,'length_cm':length_cm,'copies':1,
'rotation_degrees':0,'mirrored':False,'measurement':'customer'}],
'placements':[{'source_index':0,'copy_index':0,'x_cm':0,'y_cm':0,

View File

@@ -1,4 +1,5 @@
"""The montador: stamp sizes, and the invoiced order a sheet becomes.
"""The montador: stamp sizes, brand per stamp, and the Interno and Venda
orders a sheet becomes (fronts 7a to 7a.3).
Run against the local stack: python -m tests.stamps_test
"""
@@ -14,6 +15,7 @@ from tests.smoke_test import Client
PASSWORD = 'senha-de-teste-123'
PNG = (Path(__file__).resolve().parent / 'fixtures' / 'final-300.png').read_bytes()
INTERNAL_MISSING = 'Peça à Gestão para completar o cliente interno.'
def signed_in(email, password=PASSWORD):
@@ -55,6 +57,10 @@ def montador_item(uid, mode='avulsa'):
'quality_status': 'ok', 'quality_acknowledged': False, 'residue_accepted': 0}
def price_table(stats):
return {row['method']: row for row in stats['price_table']}
def run():
tag = secrets.token_hex(3)
su = Client()
@@ -62,27 +68,37 @@ def run():
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')}
internal = c.execute('SELECT name,cnpj,zap,mail FROM dtf_local.internal_customer').fetchone()
# The seed state: only the name, so Interno must be refused until
# Gestão completes the other fields.
c.execute("UPDATE dtf_local.internal_customer SET name='Nexstar · Marketplace',"
"cnpj='',zap='',mail=''")
emails = {role: f'{role}-{tag}@example.test' for role in ('expedicao', 'vendedor', 'designer', 'gestao')}
table = [(row['letter'], float(row['width_cm'])) for row in original]
customer = {'name': 'Cliente Montador', 'cnpj': '11222333000181', 'zap': '16999999999',
'mail': f'montador-{tag}@example.test'}
identity = operator_identity(emails['expedicao'])
internal_customer = {'name': 'Nexstar · Marketplace', 'cnpj': '11222333000181',
'zap': '1633334444', 'mail': f'interno-{tag}@example.test'}
venda_customer = {'name': 'Maria Souza', 'cnpj': '12345678909',
'zap': '16988887777', 'mail': f'venda-{tag}@example.test'}
identities = [operator_identity(emails['expedicao']), operator_identity(emails['vendedor'])]
made_orders, made_quotes = [], []
# A code of its own, so a brand someone saved in Estampas/ is never touched.
stamp_code = 'T' + tag
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'])
seller = signed_in(emails['vendedor'])
manager = signed_in(emails['gestao'])
designer = signed_in(emails['designer'])
me = shipping.call('/operator/me')
assert me['role'] == 'expedicao' and me['can'] == ['assemble', 'label', '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}]})
@@ -102,35 +118,95 @@ def run():
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
# The montador's order: the stamp upload, then the invoiced card in rec.
# The brand per stamp: read by whoever assembles, saved by Gestão.
default = shipping.call('/operator/stamps/' + stamp_code)
assert default == {'code': stamp_code, 'brand': '', 'public': False}, default
manager.call('/operator/stamps/' + stamp_code, {'brand': 'Dropstar', 'public': True})
saved = shipping.call('/operator/stamps/' + stamp_code)
assert saved == {'code': stamp_code, 'brand': 'Dropstar', 'public': True}, saved
designer.call('/operator/stamps/' + stamp_code, {'brand': 'X', 'public': False}, expected=403)
shipping.call('/operator/stamps/' + stamp_code, {'brand': 'X', 'public': False}, expected=403)
# The fake Tiny answers the Venda customer search with two contacts.
contacts = shipping.call('/operator/tiny/contacts?q=Nexstar')
assert len(contacts) == 2, contacts
assert set(contacts[0]) == {'id', 'name', 'document', 'email', 'phone'}, contacts[0]
assert contacts[0]['document'] == '11.222.333/0001-81', contacts[0]
# Interno is refused while Gestão has not completed the customer.
stamp = upload_stamp(shipping)
request_key = uuid4()
body = {'request_key': str(request_key), 'customer': customer,
'items': [montador_item(stamp)]}
order = shipping.call('/operator/montador/orders', body)
made_orders.append(UUID(order['id']))
made_quotes.append(UUID(order['quote_id']))
assert order['state'] == 'rec' and order['origin'] == 'dropflow', order
payment = order['payment']
assert (payment['provider'], payment['method'], payment['status']) == ('manual', 'faturado', 'paid'), payment
assert payment['total_cents'] == order['snapshot']['total_cents'], payment
interno = {'kind': 'interno', 'items': [montador_item(stamp)]}
refused = shipping.call('/operator/montador/orders', {'request_key': str(uuid4()), **interno},
expected=409)
assert refused['detail'] == INTERNAL_MISSING, refused
manager.call('/operator/internal-customer', internal_customer)
completed = shipping.call('/operator/internal-customer')
assert (completed['name'], completed['cnpj'], completed['zap'], completed['mail']) == (
'Nexstar · Marketplace', '11222333000181', '1633334444', internal_customer['mail']), completed
before_stats = manager.call('/operator/stats?days=30')
before = price_table(before_stats)
# Interno: the fixed customer, origin dropflow, no Tiny, no paid e-mail.
order_interno = shipping.call('/operator/montador/orders', {'request_key': str(uuid4()), **interno})
made_orders.append(UUID(order_interno['id']))
made_quotes.append(UUID(order_interno['quote_id']))
assert order_interno['state'] == 'rec' and order_interno['origin'] == 'dropflow', order_interno
assert order_interno['snapshot']['kind'] == 'interno', order_interno['snapshot'].get('kind')
assert order_interno['snapshot']['customer']['cnpj'] == '11222333000181', order_interno['snapshot']
payment = order_interno['payment']
assert (payment['provider'], payment['method'], payment['status']) == ('manual', 'interno', 'paid'), payment
with db.connect() as c:
assert c.execute('SELECT 1 FROM dtf_local.print_files WHERE order_id=%s',
(UUID(order['id']),)).fetchone()
(UUID(order_interno['id']),)).fetchone()
assert not c.execute('SELECT 1 FROM dtf_local.outbox WHERE event_key=%s',
(f"{order['id']}:paid:tiny",)).fetchone()
(f"{order_interno['id']}:paid:tiny",)).fetchone()
assert not c.execute('SELECT 1 FROM dtf_local.mail_queue WHERE to_addr=%s',
(internal_customer['mail'],)).fetchone()
# Venda: a Tiny customer, origin atendimento, invoiced and sent to Tiny.
venda_stamp = upload_stamp(seller)
venda = {'kind': 'venda', 'customer': venda_customer, 'with_order': 4321,
'items': [montador_item(venda_stamp)]}
venda_body = {'request_key': str(uuid4()), **venda}
order_venda = seller.call('/operator/montador/orders', venda_body)
made_orders.append(UUID(order_venda['id']))
made_quotes.append(UUID(order_venda['quote_id']))
assert order_venda['state'] == 'rec' and order_venda['origin'] == 'atendimento', order_venda
assert order_venda['snapshot']['with_order'] == 4321, order_venda['snapshot'].get('with_order')
payment = order_venda['payment']
assert (payment['provider'], payment['method'], payment['status']) == ('manual', 'faturado', 'paid'), payment
with db.connect() as c:
assert c.execute('SELECT 1 FROM dtf_local.outbox WHERE event_key=%s AND provider=%s',
(f"{order_venda['id']}:paid:tiny", 'tiny')).fetchone()
assert not c.execute('SELECT 1 FROM dtf_local.mail_queue WHERE to_addr=%s',
(venda_customer['mail'],)).fetchone()
# Números: both are counted apart from the money received.
after_stats = manager.call('/operator/stats?days=30')
after = price_table(after_stats)
for method, order in (('interno', order_interno), ('faturado', order_venda)):
assert after[method]['orders'] == before[method]['orders'] + 1, (method, before[method], after[method])
assert after[method]['cents'] == before[method]['cents'] + order['snapshot']['total_cents'], (method, before[method], after[method])
assert after[method]['metres'] > before[method]['metres'], (method, before[method], after[method])
assert after_stats['cents'] == before_stats['cents'], (before_stats['cents'], after_stats['cents'])
# The same montagem cannot become a second order.
refused = shipping.call('/operator/montador/orders', body, expected=409)
assert refused['detail'] == f"Esta montagem já virou o pedido #{order['number']}.", refused
# A designer does not use the montador, and only loose art becomes one.
refused = seller.call('/operator/montador/orders', venda_body, expected=409)
assert refused['detail'] == f"Esta montagem já virou o pedido #{order_venda['number']}.", refused
# Each profile makes only its own kind, and only loose art becomes one.
seller.call('/operator/montador/orders', {'request_key': str(uuid4()), **interno}, expected=403)
shipping.call('/operator/montador/orders', {'request_key': str(uuid4()), **venda}, expected=403)
designer.call('/operator/montador/uploads', {'name': 'ESTAMPA.png', 'size': 1}, expected=403)
designer.call('/operator/montador/orders', body, expected=403)
shipping.call('/operator/montador/orders', {'request_key': str(uuid4()), 'customer': customer,
designer.call('/operator/montador/orders', {'request_key': str(uuid4()), **venda}, expected=403)
shipping.call('/operator/montador/orders', {'request_key': str(uuid4()), 'kind': 'interno',
'items': [montador_item(stamp, 'file')]}, expected=422)
print('PASS: Expedição reads the sizes, uploads a stamp and gets the invoiced montador card; '
'Gestão edits the table; invalid rows, profiles and modes are refused')
print('PASS: Expedição makes Interno and Vendedor makes Venda; the internal customer, the Tiny '
'contacts, the stamp brand and the table price in Números work; invalid profiles and modes are refused')
finally:
with db.connect() as c:
if made_orders:
c.execute("DELETE FROM dtf_local.outbox WHERE payload->>'order_id' = ANY(%s::text[])",
([str(oid) for oid in made_orders],))
for oid in made_orders:
c.execute('DELETE FROM dtf_local.print_files WHERE order_id=%s', (oid,))
c.execute('DELETE FROM dtf_local.order_files WHERE order_id=%s', (oid,))
@@ -139,8 +215,13 @@ def run():
c.execute('DELETE FROM dtf_local.orders WHERE id=%s', (oid,))
if made_quotes:
c.execute('DELETE FROM dtf_local.quotes WHERE id=ANY(%s)', (made_quotes,))
c.execute('DELETE FROM dtf_local.mail_queue WHERE to_addr=%s', (customer['mail'],))
c.execute('DELETE FROM dtf_local.uploads WHERE owner=%s', (identity,))
c.execute('DELETE FROM dtf_local.mail_queue WHERE to_addr IN (%s,%s)',
(internal_customer['mail'], venda_customer['mail']))
for identity in identities:
c.execute('DELETE FROM dtf_local.uploads WHERE owner=%s', (identity,))
c.execute('DELETE FROM dtf_local.stamps WHERE code=%s', (stamp_code,))
c.execute('UPDATE dtf_local.internal_customer SET name=%s,cnpj=%s,zap=%s,mail=%s',
(internal['name'], internal['cnpj'], internal['zap'], internal['mail']))
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',))

26
tests/test_hotfolder.py Normal file
View File

@@ -0,0 +1,26 @@
"""The machine hot folder class (Fase 2, front 3), without a database."""
import unittest
from app.hotfolder import PREMIUM, contraction, folder_class
def order(mode, stroke_class='C2', chosen=None):
return {'snapshot': {'items': [{'mode': mode, 'stroke_class': stroke_class}]},
'contraction': {'0': {'class': chosen}} if chosen else {}}
class FolderClassTest(unittest.TestCase):
def test_premium_always_goes_to_its_own_folder(self):
# Marcus, 2026-11-10: every premium item, whatever its contraction class.
self.assertEqual(folder_class(order('premium', 'C3'), 0), PREMIUM)
self.assertEqual(folder_class(order('premium', 'C1', chosen='C2'), 0), PREMIUM)
def test_a_recorded_contraction_class_still_wins_for_other_products(self):
self.assertEqual(folder_class(order('file', 'C1', chosen='C2'), 0), 'C2')
self.assertEqual(folder_class(order('file'), 0), 'C2')
self.assertIsNone(contraction(order('file', None), 0))
self.assertIsNone(folder_class(order('file', None), 0))
if __name__ == '__main__':
unittest.main()

View File

@@ -2,8 +2,8 @@
import unittest
from decimal import Decimal
from app.machine_log import (ALIGN_AFTER_FILM_METRES, CLEAN_EVERY_METRES, estimate,
one_decimal, supply_low)
from app.machine_log import (ALIGN_AFTER_FILM_METRES, CLEAN_EVERY_METRES, DEFAULT_MINIMUMS,
estimate, minimum_for, one_decimal, supply_low)
class EstimateTest(unittest.TestCase):
@@ -38,6 +38,22 @@ class EstimateTest(unittest.TestCase):
self.assertEqual(CLEAN_EVERY_METRES, Decimal('10'))
self.assertEqual(ALIGN_AFTER_FILM_METRES, Decimal('20'))
def test_a_machine_without_typed_minimums_alerts_at_dropstars_defaults(self):
# Marcus, 2026-11-10: 1 roll of film, 1 L of each ink, 5 kg of powder.
self.assertEqual(DEFAULT_MINIMUMS, {'film': Decimal('1'), 'ink_c': Decimal('1'),
'ink_m': Decimal('1'), 'ink_y': Decimal('1'),
'ink_k': Decimal('1'), 'ink_w': Decimal('1'),
'powder': Decimal('5')})
for item, default in DEFAULT_MINIMUMS.items():
with self.subTest(item=item):
minimum = minimum_for({}, item)
self.assertEqual(minimum, default)
value = estimate([Decimal('1'), Decimal('1')], [Decimal('10')],
Decimal('9'), minimum)
self.assertTrue(supply_low(value))
# A minimum Gestão typed still wins over the default.
self.assertEqual(minimum_for({'film': Decimal('0')}, 'film'), Decimal('0'))
class AlertTextTest(unittest.TestCase):
def test_one_decimal_uses_a_comma(self):

View File

@@ -1,8 +1,9 @@
"""Who moves which card on the Kanban: Dropstar's flow of 2026-10-23."""
import os
import unittest
from unittest import mock
from app import payments
from app import payments, tiny
from app.core import auth
from app.core.auth import CAPABILITIES, ROLES, may_move, may_reorder
from app.runtime import BACK, STATES, TRANSITIONS
@@ -87,14 +88,31 @@ class CanAnyTest(unittest.TestCase):
route(None)
class InvoicedOrderTest(unittest.TestCase):
def test_an_invoiced_montador_order_is_held_out_of_tiny(self):
class MontadorPaymentTest(unittest.TestCase):
def test_a_faturado_order_goes_to_tiny_and_an_internal_one_does_not(self):
self.assertEqual(payments.INVOICED_METHOD, 'faturado')
# It is not one of the Cotações "registrar" methods.
self.assertEqual(payments.INTERNAL_METHOD, 'interno')
# Neither is one of the Cotações "registrar" methods.
self.assertNotIn(payments.INVOICED_METHOD, payments.OUTSIDE_METHODS)
self.assertFalse(payments.in_tiny({'payment': {'provider': 'manual', 'method': 'faturado'}}))
self.assertNotIn(payments.INTERNAL_METHOD, payments.OUTSIDE_METHODS)
self.assertTrue(payments.in_tiny({'payment': {'provider': 'manual', 'method': 'faturado'}}))
self.assertFalse(payments.in_tiny({'payment': {'provider': 'manual', 'method': 'interno'}}))
self.assertTrue(payments.in_tiny({'payment': {'provider': 'manual', 'method': 'pix'}}))
class InternalNoteTest(unittest.TestCase):
payload = {'order_id': 'b6f1c0de-0000-4000-8000-000000000001', 'number': 42,
'origin': 'atendimento', 'payment': {'method': 'faturado', 'outside': True},
'order': {'with_order': 4321}}
def test_an_invoiced_order_says_how_it_is_received(self):
with mock.patch.dict(os.environ, {'TINY_RECEIPT_BOLETO': ''}):
note = tiny.internal_note(self.payload)
self.assertIn('faturado: forma de recebimento a definir', note)
self.assertIn('junto com o pedido de roupa nº 4321', note)
with mock.patch.dict(os.environ, {'TINY_RECEIPT_BOLETO': '123456'}):
self.assertIn('faturado (Boleto)', tiny.internal_note(self.payload))
if __name__ == '__main__':
unittest.main()

View File

@@ -34,8 +34,9 @@ class PricingTests(unittest.TestCase):
def test_one_price_per_product(self):
# Dropstar, 2026-10-23: textile R$ 19,90 ready sheet and R$ 21,90 loose
# art; UV R$ 79,90 and R$ 89,90.
self.assertEqual(PRICES, {'file': 1990, 'avulsa': 2190, 'uvfile': 7990, 'uv': 8990})
# art; UV R$ 79,90 and R$ 89,90. Premium R$ 39,90 (2026-11-10).
self.assertEqual(PRICES, {'file': 1990, 'avulsa': 2190, 'uvfile': 7990, 'uv': 8990,
'premium': 3990})
self.assertEqual(price('avulsa', '2.75', 90)['total_cents'], 6132)
def test_the_grade_never_changes_the_price(self):

View File

@@ -24,7 +24,8 @@ PAID = {'order_id': 'b6f1c0de-0000-4000-8000-000000000001', 'number': 42, 'event
'state': 'SP', 'postal_code': '14400000'},
'total_cents': 8472}}
PRODUCTS = {'TINY_PRODUCT_TEXTIL_FOLHA': '101', 'TINY_PRODUCT_TEXTIL_AVULSA': '102',
'TINY_PRODUCT_UV_FOLHA': '103', 'TINY_PRODUCT_UV_AVULSA': '104', 'TINY_FORMA_ENVIO_RETIRADA': '77'}
'TINY_PRODUCT_UV_FOLHA': '103', 'TINY_PRODUCT_UV_AVULSA': '104',
'TINY_PRODUCT_TEXTIL_PREMIUM': '105', 'TINY_FORMA_ENVIO_RETIRADA': '77'}
PICKUP = {**PAID, 'order': {**PAID['order'], 'destination': None, 'freight': {'service': 'pickup', 'total_cents': 0}}}
READY = {'order_id': PAID['order_id'], 'number': 42, 'event': 'ready', 'reason': '', 'order': PICKUP['order']}
@@ -221,7 +222,7 @@ class TinyTests(FakeTinyCase):
from app.tiny import check
results = check(auth=FakeAuth(), transport=httpx.MockTransport(self.handler))
self.assertEqual(set(results.values()), {'ok'})
self.assertEqual(len(results), 7)
self.assertEqual(len(results), 8)
self.assertTrue(all(method == 'GET' for method, _ in self.calls))
self.products['103']['situacao'] = 'I'
with mock.patch.dict(os.environ, {'TINY_PRODUCT_UV_AVULSA': ''}):
@@ -794,6 +795,9 @@ class DefaultSkuTests(unittest.TestCase):
self.assertEqual(tiny.mode_codes('file'), tiny.sku_codes('DTFIMP.TX'))
self.assertEqual(tiny.mode_codes('avulsa'), tiny.sku_codes('DTFIMP.TX'))
self.assertEqual(tiny.mode_codes('uv'), ['DTFIMP.UV.1MT', 'DTFIMP.UV.010CM'])
# Premium's own catalogue: DTFIMP.TXP.100CM per metre and DTFIMP.TXP.0010CM to 0090CM (Marcus, 2026-11-11).
self.assertEqual(tiny.mode_codes('premium'), tiny.sku_codes('DTFIMP.TXP'))
self.assertIn('DTFIMP.TXP.0010CM', tiny.mode_codes('premium'))
self.assertEqual(tiny.required_settings(), ['TINY_CLIENT_ID', 'TINY_CLIENT_SECRET', 'TINY_REDIRECT_URI'])
with mock.patch.dict(os.environ, {'TINY_SKU10_UV_FOLHA': 'UV.X'}):
self.assertEqual(tiny.mode_codes('uvfile'), ['UV.X'])