fix: PRONOTE_URL ignoré à cause du double préfixe env_prefix

Le champ pronote_url dans PronoteSettings avec env_prefix=PRONOTE_
produisait PRONOTE_PRONOTE_URL au lieu de PRONOTE_URL. La variable
documentée dans .env.example et tous les guides était donc ignorée.

Renomme le champ pronote_url → url pour que le mécanisme standard
env_prefix + nom de champ produise PRONOTE_URL. Toutes les références
au champ settings.pronote.pronote_url sont mises à jour vers
settings.pronote.url dans le code de production et les tests.

Changements :
- settings.py : champ pronote_url → url, retrait du contournement alias
- client.py : self._settings.pronote_url → self._settings.url
- fallback.py : pronote.pronote_url → pronote.url
- tests : mises à jour des constructions et assertions, test de
  régression pour le mapping PRONOTE_URL → url

Co-authored-by: opencode/coder litellm/coder@agents.invalid
Co-authored-by: opencode/test-engineer litellm/test-engineer@agents.invalid
This commit is contained in:
2026-09-08 21:23:07 +02:00
parent bf4038814a
commit aa8865c22d
6 changed files with 47 additions and 34 deletions

View File

@@ -53,7 +53,7 @@ def fixture_mock_settings() -> Settings:
"""
return Settings(
pronote=PronoteSettings(
pronote_url="https://pronote.example.com",
url="https://pronote.example.com",
ical_url=SecretStr("file:///fake/ical.ics"),
agenda_source="auto",
homework_source="auto",
@@ -251,7 +251,7 @@ def test_fetch_agenda_auto_both_fail(mock_fetcher: PronoteFetcher) -> None:
:rtype: None
"""
# Disable pronotepy so fallback is None
mock_fetcher._settings.pronote.pronote_url = None
mock_fetcher._settings.pronote.url = None
with (
patch("pronote_sync.sources.pronote.fallback.fetch_ical") as m_fetch_ical,
@@ -280,7 +280,7 @@ def test_fetch_agenda_ical_mode_failure(mock_fetcher: PronoteFetcher) -> None:
"""
# Override settings to use ical mode explicitly and disable fallback
mock_fetcher._settings.pronote.agenda_source = "ical"
mock_fetcher._settings.pronote.pronote_url = None
mock_fetcher._settings.pronote.url = None
with (
patch("pronote_sync.sources.pronote.fallback.fetch_ical") as m_fetch_ical,
@@ -438,7 +438,7 @@ def test_fetch_homework_auto_both_fail(mock_fetcher: PronoteFetcher) -> None:
target_date = date(2025, 9, 10)
# Disable pronotepy so fallback is None
mock_fetcher._settings.pronote.pronote_url = None
mock_fetcher._settings.pronote.url = None
with (
patch("pronote_sync.sources.pronote.fallback.fetch_ical") as m_fetch_ical,
@@ -531,7 +531,7 @@ def test_no_secrets_in_error_messages(
:rtype: None
"""
# Disable pronotepy so fallback is None to trigger PipelineCriticalError
mock_fetcher._settings.pronote.pronote_url = None
mock_fetcher._settings.pronote.url = None
with (
patch("pronote_sync.sources.pronote.fallback.fetch_ical") as m_fetch_ical,
@@ -629,7 +629,7 @@ def test_fetch_agenda_no_source_configured_raises(mock_fetcher: PronoteFetcher)
"""
# Disable both sources
mock_fetcher._settings.pronote.ical_url = None
mock_fetcher._settings.pronote.pronote_url = None
mock_fetcher._settings.pronote.url = None
with pytest.raises(PipelineCriticalError) as exc_info:
mock_fetcher.fetch_agenda()
@@ -1020,7 +1020,7 @@ def test_homework_sources_explicit_ical_mode_strict(mock_fetcher: PronoteFetcher
assert fallback is None
# Without pronotepy configured
mock_fetcher._settings.pronote.pronote_url = None
mock_fetcher._settings.pronote.url = None
primary, fallback = mock_fetcher._homework_sources()
assert primary == "ical"
assert fallback is None
@@ -1080,7 +1080,7 @@ def test_homework_sources_auto_no_source_configured_raises(mock_fetcher: Pronote
"""
mock_fetcher._settings.pronote.homework_source = "auto"
mock_fetcher._settings.pronote.ical_url = None
mock_fetcher._settings.pronote.pronote_url = None
mock_fetcher._settings.pronote.url = None
with pytest.raises(PipelineCriticalError) as exc_info:
mock_fetcher._homework_sources()
@@ -1298,7 +1298,7 @@ def test_is_pronotepy_configured_without_ent_returns_true() -> None:
# Créer des settings avec pronotepy configuré mais sans ent
settings = Settings(
pronote=PronoteSettings(
pronote_url="https://pronote.example.com",
url="https://pronote.example.com",
username="testuser",
password=SecretStr("testpass"),
ent=None, # Explicitement None
@@ -1327,7 +1327,7 @@ def test_agenda_sources_auto_without_ical_and_without_ent_returns_pronotepy() ->
settings = Settings(
pronote=PronoteSettings(
pronote_url="https://pronote.example.com",
url="https://pronote.example.com",
username="testuser",
password=SecretStr("testpass"),
ent=None, # Explicitement None
@@ -1358,7 +1358,7 @@ def test_homework_sources_auto_without_ical_and_without_ent_returns_pronotepy()
settings = Settings(
pronote=PronoteSettings(
pronote_url="https://pronote.example.com",
url="https://pronote.example.com",
username="testuser",
password=SecretStr("testpass"),
ent=None, # Explicitement None