From ff9078d278ae44b6ec90f111cba1bfcb454d4cea Mon Sep 17 00:00:00 2001 From: Maria Antonia Date: Sat, 24 Jun 2023 09:41:49 -0300 Subject: [PATCH] =?UTF-8?q?=20Melhorar=20os=20testes=20do=20m=C3=A9todo=20?= =?UTF-8?q?parse=20do=20CNPJ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- brutils/cnpj.py | 7 +------ tests/test_cnpj.py | 11 +++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/brutils/cnpj.py b/brutils/cnpj.py index 9e64e2b..540d199 100644 --- a/brutils/cnpj.py +++ b/brutils/cnpj.py @@ -17,12 +17,7 @@ def sieve(dirty): # type: (str) -> str def parse(dirty): # type: (str) -> str - """ - Filters out CNPJ formatting symbols. Symbols that are not used - in the CNPJ formatting are left unfiltered on purpose so that - if fails other tests, because their presence indicate that the - input was somehow corrupted. - """ + """Alias to the function `sieve`. Better naming.""" return sieve(dirty) diff --git a/tests/test_cnpj.py b/tests/test_cnpj.py index 7f95949..40ab7e6 100644 --- a/tests/test_cnpj.py +++ b/tests/test_cnpj.py @@ -2,6 +2,7 @@ from os.path import abspath, join, dirname from sys import path, version_info, dont_write_bytecode from inspect import getsourcefile +from unittest.mock import patch dont_write_bytecode = True range = range if version_info.major >= 3 else xrange @@ -32,12 +33,10 @@ def test_sieve(self): assert sieve("/...---.../") == "" def test_parse(self): - assert parse("00000000000") == "00000000000" - assert parse("12.345.678/0001-90") == "12345678000190" - assert parse("134..2435/.-1892.-") == "13424351892" - assert parse("abc1230916*!*&#") == "abc1230916*!*&#" - assert parse("ab.c1.--.2-3/09.-1-./6/-.*.-!*&#") == "abc1230916*!*&#" - assert parse("/...---.../") == "" + with patch("brutils.cnpj.sieve") as mock_sieve: + # When call parse, it calls sieve + parse("12.345.678/0001-90") + mock_sieve.assert_called() def test_display(self): assert display("00000000000109") == "00.000.000/0001-09"