0cfafedeef
Override CSS scopé aux classes .btn-* (jamais les variables --bs-* racine,
donc alertes/badges inchangés) pour remplacer les couleurs dérivées du thème
Simplex (danger mauve, secondary gris illisible). Trois rôles : la couleur
encode la fonction, le remplissage l'emphase.
- primary terracotta : action principale validante
- secondary gris ardoise : action neutre/alternative (lisible)
- danger rouge #c0392b : destructif (outline par défaut, plein en confirmation)
Audit + conformation des usages :
- compte_admin « Supprimer mon compte » : primary outline -> danger outline
- compte_abonnement « Me désabonner » : outline-primary -> outline-danger
- compte_abonnement « Je suis sûr » : outline-primary -> danger plein
Tests : ajout tests/test_boutons.py (garde de non-régression du primary).
conftest : implémente le hook pytest_setup_options (--headless=new) ; la
fixture chrome_options n'était jamais utilisée par dash.testing, d'où les
fenêtres Chrome qui s'ouvraient pendant les tests.
Specs et plan : docs/superpowers/{specs,plans}/2026-06-30-charte-boutons*.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
91 lines
3.1 KiB
Python
91 lines
3.1 KiB
Python
import datetime
|
|
import os
|
|
from pathlib import Path
|
|
|
|
import polars as pl
|
|
import pytest
|
|
from selenium.webdriver.chrome.options import Options
|
|
|
|
_TEST_DATA = [
|
|
{
|
|
"uid": "1",
|
|
"id": "1",
|
|
"acheteur_nom": "ACHETEUR 1",
|
|
"acheteur_id": "123",
|
|
"titulaire_nom": "TITULAIRE 1",
|
|
"titulaire_id": "345",
|
|
"montant": 10,
|
|
"dateNotification": datetime.date(2025, 1, 1),
|
|
"codeCPV": "71600000",
|
|
"donneesActuelles": True,
|
|
"acheteur_departement_code": "75",
|
|
"acheteur_departement_nom": "Paris",
|
|
"acheteur_commune_nom": "Paris",
|
|
"titulaire_departement_code": "35",
|
|
"titulaire_departement_nom": "Ille-et-Vilaine",
|
|
"titulaire_commune_nom": "Rennes",
|
|
"titulaire_distance": 10,
|
|
"titulaire_typeIdentifiant": "SIRET",
|
|
"objet": "Objet test",
|
|
"dureeRestanteMois": 12,
|
|
"lieuExecution_code": "75001",
|
|
"sourceFile": "test.xml",
|
|
"sourceDataset": "test_dataset",
|
|
"datePublicationDonnees": datetime.date(2025, 1, 1),
|
|
"considerationsSociales": "",
|
|
"considerationsEnvironnementales": "",
|
|
"type": "Marché",
|
|
"acheteur_categorie": "Collectivité",
|
|
"titulaire_categorie": "PME",
|
|
}
|
|
]
|
|
_PARQUET_PATH = Path(os.path.abspath("tests/test.parquet"))
|
|
_DB_PATH = Path(os.path.abspath("decp.duckdb"))
|
|
|
|
# Schéma déterministe et hors-ligne pour les tests : on pointe le cache sur un
|
|
# fixture commité et on désactive la récupération distante.
|
|
_SCHEMA_FIXTURE = Path(os.path.abspath("tests/schema.fixture.json"))
|
|
os.environ["DATA_SCHEMA_CACHE"] = str(_SCHEMA_FIXTURE)
|
|
os.environ.pop("DATA_SCHEMA_PATH", None)
|
|
|
|
|
|
def _cleanup_db_artifacts() -> None:
|
|
for artifact in (
|
|
_DB_PATH,
|
|
_DB_PATH.with_suffix(".duckdb.tmp"),
|
|
_DB_PATH.with_suffix(".duckdb.lock"),
|
|
):
|
|
if artifact.exists():
|
|
artifact.unlink()
|
|
|
|
|
|
# Runs at conftest import, before test modules import src.db (which builds the
|
|
# DuckDB at import time). Guarantees the test parquet exists and the stale DB
|
|
# from a previous `python run.py` is wiped so src.db rebuilds from test data.
|
|
pl.DataFrame(_TEST_DATA).write_parquet(_PARQUET_PATH)
|
|
_cleanup_db_artifacts()
|
|
|
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
|
def test_data():
|
|
yield str(_PARQUET_PATH)
|
|
# Teardown: remove the test DuckDB so the next `python run.py` rebuilds
|
|
# from decp_prod.parquet.
|
|
_cleanup_db_artifacts()
|
|
|
|
|
|
def pytest_setup_options():
|
|
"""Options Chrome pour les tests d'intégration Selenium.
|
|
|
|
dash.testing n'utilise PAS une fixture `chrome_options` (contrairement à
|
|
pytest-selenium) : il appelle ce hook `pytest_setup_options`. C'est donc le
|
|
seul point d'entrée qui a réellement un effet. On force `--headless=new`
|
|
pour qu'aucune fenêtre Chrome ne s'ouvre pendant les tests. Le dossier de
|
|
téléchargement, `--no-sandbox`, `--disable-gpu` et `--disable-dev-shm-usage`
|
|
sont déjà gérés par dash.testing.browser.
|
|
"""
|
|
options = Options()
|
|
options.add_argument("--headless=new")
|
|
options.add_argument("--window-size=1200,1200")
|
|
return options
|