Skip to content

Commit c3c8792

Browse files
committed
Add test coverage for ArgentinaApiProvider initialization
1 parent c2e85c6 commit c3c8792

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/test_services.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
from app.config.config import Config
1010
from app.models.models import Holiday
11+
from app.services.holiday_providers.argentina_api_provider import (
12+
ArgentinaApiProvider,
13+
)
1114
from app.services.holiday_providers.argentina_website_provider import (
1215
ArgentinaWebsiteProvider,
1316
)
@@ -131,6 +134,7 @@ class TestHolidayService:
131134
class MockConfig(Config):
132135
HOLIDAY_PROVIDER = "ARGENTINA_WEBSITE"
133136
HOLIDAYS_BASE_URL = "http://fake-url.com/{year}"
137+
HOLIDAY_API_URL = "http://fake-api.com/{year}"
134138

135139
def test_get_holiday_provider_success(self):
136140
"""
@@ -172,6 +176,29 @@ class MissingUrlConfig(TestHolidayService.MockConfig):
172176
with pytest.raises(ValueError, match="HOLIDAYS_BASE_URL is not configured"):
173177
get_holiday_provider(MissingUrlConfig)
174178

179+
def test_get_holiday_provider_api_success(self):
180+
"""
181+
Test that the factory returns the correct API provider instance.
182+
"""
183+
184+
class ApiConfig(TestHolidayService.MockConfig):
185+
HOLIDAY_PROVIDER = "ARGENTINA_API"
186+
187+
provider = get_holiday_provider(ApiConfig)
188+
assert isinstance(provider, ArgentinaApiProvider)
189+
190+
def test_get_holiday_provider_api_missing_url(self):
191+
"""
192+
Test that a ValueError is raised if the API URL is missing.
193+
"""
194+
195+
class MissingApiUrlConfig(TestHolidayService.MockConfig):
196+
HOLIDAY_PROVIDER = "ARGENTINA_API"
197+
HOLIDAY_API_URL = None # type: ignore[assignment]
198+
199+
with pytest.raises(ValueError, match="HOLIDAY_API_URL is not configured"):
200+
get_holiday_provider(MissingApiUrlConfig)
201+
175202
def test_get_holiday_provider_not_implemented(self):
176203
"""
177204
Test that a NotImplementedError is raised for a provider without init logic.

0 commit comments

Comments
 (0)