Skip to content

Commit f353033

Browse files
committed
Improve test coverage for ArgentinaApiProvider parsing exceptions
1 parent c3c8792 commit f353033

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/test_argentina_api_provider.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,23 @@ def test_get_holidays_json_error(self, mock_response):
9090
with patch("requests.get", return_value=mock_response):
9191
holidays = provider.get_holidays(2025)
9292
assert holidays == []
93+
94+
def test_get_holidays_parsing_exceptions(self, mock_response):
95+
"""
96+
Test that parsing exceptions (ValueError, AttributeError) are caught.
97+
"""
98+
year = 2025
99+
mock_response.json.return_value = [
100+
# Good entry
101+
{"fecha": "2025-01-01", "nombre": "Good", "tipo": "inamovible"},
102+
# ValueError: Invalid date format (strptime fails)
103+
{"fecha": "invalid-01-01", "nombre": "Bad Date Format", "tipo": "inamovible"},
104+
# AttributeError: Entry is not a dict (no .get method)
105+
"invalid_string_entry",
106+
]
107+
provider = ArgentinaApiProvider(api_url="http://fake-api.com/{year}")
108+
with patch("requests.get", return_value=mock_response):
109+
holidays = provider.get_holidays(year)
110+
# Should only contain the valid holiday
111+
assert len(holidays) == 1
112+
assert holidays[0].description == "Good"

0 commit comments

Comments
 (0)