Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Melhorar os testes do método parse do CNPJ #107

Merged
merged 2 commits into from
Jun 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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