Skip to content

Commit

Permalink
Update tests to coverage 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
mstuttgart committed Sep 5, 2024
1 parent c1ef0f9 commit 49ee3fd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from brazilcep import WebService, get_address_from_cep
from brazilcep.client import _format_cep


def test_search_error():
with pytest.raises(KeyError):
get_address_from_cep("37.503-130", webservice=5)
Expand Down Expand Up @@ -44,3 +43,16 @@ def test_format_cep_fail():

with pytest.raises(ValueError):
_format_cep(True)

def test_a_deprecated_enum_value():

with catch_warnings(record=True) as w:
# ADeprecatedEnum.FOO is not deprecated and should not throw any warning
get_address_from_cep("37.503-130", webservice=WebService.OPENCEP)
assert len(w) == 0

# ADeprecatedEnum.BAR is deprecated and we expect to have a warning raised.
get_address_from_cep("37.503-130", webservice=WebService.CORREIOS)
assert len(w) == 1
assert issubclass(w[0].category, DeprecationWarning)
assert str(w[0].message) == 'CORREIOS is going to be deprecated. Please, use other webservice.'

0 comments on commit 49ee3fd

Please sign in to comment.