|
8 | 8 |
|
9 | 9 | from app.config.config import Config |
10 | 10 | from app.models.models import Holiday |
| 11 | +from app.services.holiday_providers.argentina_api_provider import ( |
| 12 | + ArgentinaApiProvider, |
| 13 | +) |
11 | 14 | from app.services.holiday_providers.argentina_website_provider import ( |
12 | 15 | ArgentinaWebsiteProvider, |
13 | 16 | ) |
@@ -131,6 +134,7 @@ class TestHolidayService: |
131 | 134 | class MockConfig(Config): |
132 | 135 | HOLIDAY_PROVIDER = "ARGENTINA_WEBSITE" |
133 | 136 | HOLIDAYS_BASE_URL = "http://fake-url.com/{year}" |
| 137 | + HOLIDAY_API_URL = "http://fake-api.com/{year}" |
134 | 138 |
|
135 | 139 | def test_get_holiday_provider_success(self): |
136 | 140 | """ |
@@ -172,6 +176,29 @@ class MissingUrlConfig(TestHolidayService.MockConfig): |
172 | 176 | with pytest.raises(ValueError, match="HOLIDAYS_BASE_URL is not configured"): |
173 | 177 | get_holiday_provider(MissingUrlConfig) |
174 | 178 |
|
| 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 | + |
175 | 202 | def test_get_holiday_provider_not_implemented(self): |
176 | 203 | """ |
177 | 204 | Test that a NotImplementedError is raised for a provider without init logic. |
|
0 commit comments