fix(gui): connecter la GUI V6 au portail prod (P0-2, plus localhost)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ La fenêtre n'est créée qu'à l'instanciation de :class:`AnonymisationApp`.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
import customtkinter as ctk
|
||||
@@ -23,6 +24,14 @@ from gui_v6.tabs.tab_about import AboutTab
|
||||
from gui_v6.tabs.tab_config import ConfigTab
|
||||
from gui_v6.tabs.tab_usage import UsageTab
|
||||
|
||||
DEFAULT_PORTAL_URL = "https://app.aivanov.eu"
|
||||
|
||||
|
||||
def resolve_portal_url() -> str:
|
||||
"""URL du portail : env ``ANON_PORTAL_URL`` sinon défaut prod."""
|
||||
return os.environ.get("ANON_PORTAL_URL", DEFAULT_PORTAL_URL)
|
||||
|
||||
|
||||
_TABS = [
|
||||
("use", "📄 Utilisation"),
|
||||
("cfg", "⚙️ Administration"),
|
||||
@@ -38,7 +47,7 @@ class AnonymisationApp(ctk.CTk):
|
||||
) -> None:
|
||||
super().__init__()
|
||||
self._theme_name = theme_name
|
||||
self._license_client = license_client or LicenseClient("http://localhost")
|
||||
self._license_client = license_client or LicenseClient(resolve_portal_url())
|
||||
self._config = ConfigState()
|
||||
self._active = "use"
|
||||
self._tab_buttons: dict = {}
|
||||
@@ -196,7 +205,7 @@ class AnonymisationApp(ctk.CTk):
|
||||
if session is None:
|
||||
return
|
||||
status = self._safe_local_status()
|
||||
base_url = getattr(self._license_client, "_base_url", "") or "http://localhost"
|
||||
base_url = getattr(self._license_client, "_base_url", "") or resolve_portal_url()
|
||||
usage_telemetry.report_run_summary(
|
||||
summary,
|
||||
base_url=base_url,
|
||||
|
||||
14
tests/unit/test_gui_v6_portal_url.py
Normal file
14
tests/unit/test_gui_v6_portal_url.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import pytest
|
||||
|
||||
|
||||
def test_default_portal_url_is_prod(monkeypatch):
|
||||
monkeypatch.delenv("ANON_PORTAL_URL", raising=False)
|
||||
from gui_v6.app import DEFAULT_PORTAL_URL, resolve_portal_url
|
||||
assert DEFAULT_PORTAL_URL == "https://app.aivanov.eu"
|
||||
assert resolve_portal_url() == "https://app.aivanov.eu"
|
||||
|
||||
|
||||
def test_portal_url_env_override(monkeypatch):
|
||||
monkeypatch.setenv("ANON_PORTAL_URL", "http://localhost:8088")
|
||||
from gui_v6.app import resolve_portal_url
|
||||
assert resolve_portal_url() == "http://localhost:8088"
|
||||
Reference in New Issue
Block a user