From 49ee3fd9f515479d8b96e1112a9248fbc75a1d97 Mon Sep 17 00:00:00 2001 From: Michell Stuttgart Date: Thu, 5 Sep 2024 17:11:03 -0300 Subject: [PATCH] Update tests to coverage 100% --- tests/test_client.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/test_client.py b/tests/test_client.py index 6f05089..0f013b5 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -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) @@ -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.'