Skip to content

Commit a22b963

Browse files
committed
Add tests to check the constants
1 parent ac9981c commit a22b963

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

tests/sgs/test_regional_economy.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import pytest
33
from bcb.sgs.regional_economy import get_non_performing_loans, get_non_performing_loans_codes
44
from bcb.utils import BRAZILIAN_REGIONS
5+
from bcb.sgs import regional_economy
56

67

78
class TestGetNonPerformingLoansCodes:
@@ -34,3 +35,33 @@ def test_get_series_by_region_pj(self):
3435
assert isinstance(series, pd.DataFrame)
3536
assert (series.columns == south_states).all()
3637
assert len(series) == 5
38+
39+
40+
class TestNonPerformingLoansCodes:
41+
@pytest.fixture
42+
def non_performing_constants(self):
43+
constants = [
44+
item
45+
for item in dir(regional_economy)
46+
if item.startswith("NON_PERFORMING_LOANS_BY")
47+
]
48+
return constants
49+
50+
def test_if_all_regions_and_states_are_there(self, non_performing_constants):
51+
states = []
52+
for state in BRAZILIAN_REGIONS.values():
53+
states.extend(state)
54+
for item_str in non_performing_constants:
55+
item = getattr(regional_economy, item_str)
56+
if "REGION" in str(item):
57+
assert (list(item.values()) == list(BRAZILIAN_REGIONS.keys())), item_str
58+
elif "STATE" in str(item):
59+
assert (list(item.values()) == states), item_str
60+
61+
def test_check_if_codes_are_unique(self, non_performing_constants):
62+
for item_str in non_performing_constants:
63+
item = getattr(regional_economy, item_str)
64+
65+
unique_values = set(item.values())
66+
assert all(unique_values), item_str
67+
assert (len(item.values()) == len(unique_values)), item_str

0 commit comments

Comments
 (0)