Skip to content

Commit

Permalink
Melhorar os testes do método parse do CNPJ (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniamaia committed Jun 24, 2023
1 parent 0c802cf commit 5ad023f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
7 changes: 1 addition & 6 deletions brutils/cnpj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
11 changes: 5 additions & 6 deletions tests/test_cnpj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 5ad023f

Please sign in to comment.