Skip to content

Commit

Permalink
Updates the Display Adress to remove asterisk in the PLP
Browse files Browse the repository at this point in the history
  • Loading branch information
francielly.silva authored and lucaspolo committed Jan 4, 2021
1 parent 942e77d commit 893490a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
11 changes: 10 additions & 1 deletion correios/models/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,16 @@ def label_name(self) -> str:

@property
def display_address(self) -> Tuple[str, str]:
address = "{}, {} - {}".format(self.street, self.raw_number, self.complement)
number = ""
complement = ""

if self.number:
number = ", {}".format(self.number)

if self.complement:
complement = " - {}".format(self.complement)

address = "{}{}{}".format(self.street, number, complement)
city = "{} / {} - {}".format(self.city, self.state, self.zip_code.display())
return address.strip(), city.strip()

Expand Down
27 changes: 27 additions & 0 deletions tests/test_address_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,30 @@ def test_custom_address_label_address_long_street_name(address_class):
assert 'Vila' in address.label_address
assert '1234' in address.label_address
assert 'Ap 01' in address.label_address


@pytest.mark.parametrize(
'street, number, complement, result', [
('Rua Tiradentes, 199', '*', 'Ap 01', 'Rua Tiradentes, 199 - Ap 01'),
('Rua Saudade', '222', 'Bloco C', 'Rua Saudade, 222 - Bloco C'),
('Rua Guanabara, 111', '*', '', 'Rua Guanabara, 111')
]
)
def test_should_remove_asterisk_from_display_address(
street,
number,
complement,
result
):
address = Address(
name="Maria Moras",
street=street,
number=number,
city="Botelhos",
state="MG",
zip_code="37720-000",
neighborhood="Posto do Loyola",
complement=complement
)

assert address.display_address[0] == result

0 comments on commit 893490a

Please sign in to comment.