81 lines
3.0 KiB
Python
81 lines
3.0 KiB
Python
"""Garde-fou : l'onglet Configuration doit couvrir les sections de la maquette V6."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
pytest.importorskip("customtkinter")
|
|
|
|
from gui_v6.tabs.tab_config import (
|
|
CONFIG_INTERACTION_CONTRACT,
|
|
CONFIG_MOCKUP_SECTIONS,
|
|
MINI_TOGGLE_HEIGHT,
|
|
MINI_TOGGLE_HINT_FONT_SIZE,
|
|
MINI_TOGGLE_LABEL_FONT_SIZE,
|
|
_DETECTION_OPTIONS,
|
|
)
|
|
|
|
|
|
def test_config_mockup_sections_cover_admin_surface():
|
|
assert CONFIG_MOCKUP_SECTIONS == {
|
|
"reglages": [
|
|
"Profil d'anonymisation",
|
|
"Moteurs NER",
|
|
"Données à détecter",
|
|
"Termes à toujours conserver",
|
|
"Termes à toujours masquer",
|
|
"Masque manuel obligatoire",
|
|
"Template de masque manuel",
|
|
],
|
|
"masquage": [
|
|
"Couleur de masquage (PDF)",
|
|
"Style des marqueurs (texte)",
|
|
"Épaisseur du masque",
|
|
"Codes de remplacement",
|
|
"Masques de zones fixes",
|
|
"Éditeur interactif de masques",
|
|
],
|
|
"partage": ["Exporter la configuration", "Importer une configuration"],
|
|
"regles": ["Règles actives", "Testeur de règle"],
|
|
}
|
|
|
|
|
|
def test_config_interaction_contract_prebuilds_panels_and_mask_editor():
|
|
assert CONFIG_INTERACTION_CONTRACT["subtabs"] == "prebuilt_panels"
|
|
assert CONFIG_INTERACTION_CONTRACT["reglages_columns"] == 3
|
|
assert CONFIG_INTERACTION_CONTRACT["mask_editor"] == [
|
|
"open_pdf",
|
|
"draw_rectangle",
|
|
"delete_rectangle_on_click",
|
|
"zoom",
|
|
"save_template_json",
|
|
"load_template_json_or_yaml",
|
|
"clear_page",
|
|
"apply_template_selection",
|
|
]
|
|
|
|
|
|
def test_detection_options_fields_match_category_fields():
|
|
"""Garde-fou anti-dérive : les champs déclarés dans _DETECTION_OPTIONS doivent
|
|
rester alignés (mêmes champs ET même ordre) sur CATEGORY_FIELDS, sinon un
|
|
toggle pointerait vers un attribut ConfigState inexistant (AttributeError au
|
|
lancement de la GUI au lieu d'un échec de test)."""
|
|
from gui_v6.config_state import CATEGORY_FIELDS, ConfigState
|
|
|
|
fields = [field for _l, _h, field in _DETECTION_OPTIONS]
|
|
assert fields == list(CATEGORY_FIELDS) # mêmes champs ET même ordre (ordre UI = ordre catégories)
|
|
for f in fields: # chacun est bien un booléen réel de ConfigState
|
|
assert isinstance(getattr(ConfigState(), f), bool)
|
|
|
|
|
|
def test_detection_rows_are_readable_in_light_theme():
|
|
"""Retour Dom : les sous-labels de la colonne détection doivent rester lisibles."""
|
|
# Chaque ligne est désormais (libellé, aide, champ ConfigState) ; on ne
|
|
# vérifie ici que le couple (libellé, aide) reste lisible.
|
|
label_hint = [(label, hint) for label, hint, _field in _DETECTION_OPTIONS]
|
|
assert ("Noms et prénoms", "Annuaire + IA") in label_hint
|
|
assert ("Noms et prénoms", "Bases de données + IA") not in label_hint
|
|
assert MINI_TOGGLE_HEIGHT >= 44
|
|
assert MINI_TOGGLE_LABEL_FONT_SIZE >= 12
|
|
assert MINI_TOGGLE_HINT_FONT_SIZE >= 11
|