From b89fd42420ec87a298b30166773797a98a25b939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Paiva?= Date: Sat, 24 Feb 2024 20:16:38 -0300 Subject: [PATCH] =?UTF-8?q?test:=20Atualiza=20configura=C3=A7=C3=B5es=20de?= =?UTF-8?q?=20coverage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .coveragerc | 8 ++++++++ tests/__init__.py | 1 - tests/test_CNPJ.py | 35 ++++++++++++++++++++++++++++++++++- tests/test_generic.py | 4 ++-- 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..2dc3d8b --- /dev/null +++ b/.coveragerc @@ -0,0 +1,8 @@ +[run] +source = validate_docbr +disable_warnings = no-data-collected + +[report] +fail_under = 97.50 +precision = 2 +show_missing = True diff --git a/tests/__init__.py b/tests/__init__.py index ecadf74..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +0,0 @@ -from tests import * diff --git a/tests/test_CNPJ.py b/tests/test_CNPJ.py index 1eea631..cfcfe9e 100644 --- a/tests/test_CNPJ.py +++ b/tests/test_CNPJ.py @@ -29,7 +29,7 @@ def test_mask(self): self.assertEqual(masked_cnpj, '11.222.333/4444-55') def test_special_case(self): - """ Verifica os casos especiais de CNPJ """ + """Verifica os casos especiais de CNPJ.""" cases = [ ('00000-000/0000', False), ('AAAA0AAAAAAA2AAAAAA', False), @@ -37,3 +37,36 @@ def test_special_case(self): ] for cnpj, is_valid in cases: self.assertEqual(self.cnpj.validate(cnpj), is_valid) + + def test_validate_success(self): + """Testar o método validate do CNPJ.""" + # GIVEN + doc = '74600269000145' + + # WHEN + validate_return = self.cnpj.validate(doc) + + # THEN + self.assertTrue(validate_return) + + def test_validate_wrong_input(self): + """Testar o método validate do CNPJ em caso de input errado.""" + # GIVEN + doc = '74600269000145_' + + # WHEN + validate_return = self.cnpj.validate(doc) + + # THEN + self.assertFalse(validate_return) + + def test_validate_wrong_length(self): + """Testar o método validate do CNPJ em caso de tamanho inválido.""" + # GIVEN + doc = '746002690001450' + + # WHEN + validate_return = self.cnpj.validate(doc) + + # THEN + self.assertFalse(validate_return) diff --git a/tests/test_generic.py b/tests/test_generic.py index 60c1f87..2cbb0dd 100644 --- a/tests/test_generic.py +++ b/tests/test_generic.py @@ -1,5 +1,5 @@ -import unittest import random +import unittest import validate_docbr as docbr @@ -34,7 +34,7 @@ def test_correct_argument(self): # Documentos aleatórios len_doc = len(DocClass().generate()) - for i in range(200): + for _ in range(200): random_doc = get_random_number_str(len_doc) documents += [(DocClass, random_doc)] right_answers += [DocClass().validate(random_doc)]