Skip to content

Commit

Permalink
Renomear métodos parse para algum nome que seja mais explícito
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniamaia committed Jun 25, 2023
1 parent 5ad023f commit 929e25b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions brutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from brutils.cpf import (
is_valid as is_valid_cpf,
format_cpf,
parse as parse_cpf,
remove_symbols as remove_symbols_cpf,
generate as generate_cpf,
)
from brutils.cnpj import (
is_valid as is_valid_cnpj,
format_cnpj,
parse as parse_cnpj,
remove_symbols as remove_symbols_cnpj,
generate as generate_cnpj,
)
2 changes: 1 addition & 1 deletion brutils/cnpj.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def sieve(dirty): # type: (str) -> str
return "".join(filter(lambda char: char not in "./-", dirty))


def parse(dirty): # type: (str) -> str
def remove_symbols(dirty): # type: (str) -> str
"""Alias to the function `sieve`. Better naming."""
return sieve(dirty)

Expand Down
2 changes: 1 addition & 1 deletion brutils/cpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def sieve(dirty): # type: (str) -> str
return "".join(filter(lambda char: char not in ".-", dirty))


def parse(dirty): # type: (str) -> str
def remove_symbols(dirty): # type: (str) -> str
"""Alias to the function `sieve`. Better naming."""
return sieve(dirty)

Expand Down
12 changes: 6 additions & 6 deletions tests/test_cnpj.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
generate,
is_valid,
format_cnpj,
parse,
remove_symbols,
)
from unittest import TestCase, main

Expand All @@ -32,11 +32,11 @@ def test_sieve(self):
assert sieve("ab.c1.--.2-3/09.-1-./6/-.*.-!*&#") == "abc1230916*!*&#"
assert sieve("/...---.../") == ""

def test_parse(self):
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_remove_symbols(self):
with patch("brutils.cnpj.remove_symbols") as mock_remove_symbols:
# When call remove_symbols, it calls sieve
remove_symbols("12.345.678/0001-90")
mock_remove_symbols.assert_called()

def test_display(self):
assert display("00000000000109") == "00.000.000/0001-09"
Expand Down
12 changes: 6 additions & 6 deletions tests/test_cpf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
generate,
is_valid,
format_cpf,
parse,
remove_symbols,
_hashdigit,
_checksum,
)
Expand All @@ -32,11 +32,11 @@ def test_sieve(self):
assert sieve("ab.c1.--.2-309.-1-.6-.*.-!*&#") == "abc1230916*!*&#"
assert sieve("...---...") == ""

def test_parse(self):
with patch("brutils.cpf.sieve") as mock_sieve:
# When call parse, it calls sieve
parse("123.456.789-10")
mock_sieve.assert_called()
def test_remove_symbols(self):
with patch("brutils.cpf.remove_symbols") as mock_remove_symbols:
# When call remove_symbols, it calls sieve
remove_symbols("123.456.789-10")
mock_remove_symbols.assert_called()

def test_display(self):
assert display("00000000011") == "000.000.000-11"
Expand Down

0 comments on commit 929e25b

Please sign in to comment.