All checks were successful
Build and deploy / Validate source (push) Successful in 10s
Build and deploy / Integration suite on a real stack (push) Successful in 4m49s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Successful in 1m15s
The Site asked only for CPF/CNPJ, WhatsApp and e-mail, so a person's Tiny contact was named after the recipient or the e-mail, and the WhatsApp notices the client's n8n sends from Tiny greeted "Olá, fulano@gmail.com". The cart's "Seus dados" and the signup now ask for a name, the account page can change it, and it names a CPF customer's Tiny contact (a CNPJ keeps the registry's razão social), the Kanban card and the team's alerts. Orders placed before have none, as the server still accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
"""The customer's document: a CPF (a person) or a CNPJ (a company), with its
|
|
check digits. Runs where pydantic is installed."""
|
|
import unittest
|
|
|
|
from pydantic import ValidationError
|
|
|
|
from app.core.models import Customer
|
|
|
|
|
|
def customer(document):
|
|
return Customer(cnpj=document, zap='16999999999', mail='loja@example.test')
|
|
|
|
|
|
class CustomerDocumentTest(unittest.TestCase):
|
|
def test_a_cpf_or_a_cnpj_is_kept_as_digits(self):
|
|
self.assertEqual(customer('529.982.247-25').cnpj, '52998224725')
|
|
self.assertEqual(customer('11.222.333/0001-81').cnpj, '11222333000181')
|
|
self.assertEqual(customer('55786635000158').cnpj, '55786635000158')
|
|
|
|
def test_wrong_check_digits_repeated_digits_and_other_lengths_are_refused(self):
|
|
for document in ('529.982.247-24', '111.111.111-11', '11.222.333/0001-82', '00000000000000',
|
|
'5299822472', '529982247250', '١١٢٢٢٣٣٣٠٠٠١٨١'):
|
|
with self.subTest(document=document), self.assertRaises(ValidationError):
|
|
customer(document)
|
|
|
|
|
|
class CustomerNameTest(unittest.TestCase):
|
|
def test_a_name_is_tidied_and_may_be_left_out_by_older_carts(self):
|
|
self.assertEqual(Customer(cnpj='52998224725', zap='16999999999', mail='a@example.test',
|
|
name=' Maria da Silva ').name, 'Maria da Silva')
|
|
self.assertEqual(customer('52998224725').name, '')
|
|
for name in ('1', 'A', '-- .'):
|
|
with self.subTest(name=name), self.assertRaises(ValidationError):
|
|
Customer(cnpj='52998224725', zap='16999999999', mail='a@example.test', name=name)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|