Afficher l'IP client (x-forwarded-for) dans les logs des requêtes API
This commit is contained in:
@ -111,6 +111,45 @@ def test_preview_rejects_unknown_viz():
|
||||
assert "inconnu" in e.detail
|
||||
|
||||
|
||||
def test_preset_sanitize_and_upsert(tmp_path, monkeypatch):
|
||||
"""Presets de couches : valeurs assainies, remplacées par identifiant."""
|
||||
import lidar_pipeline.webapp as webapp
|
||||
monkeypatch.setattr(webapp, "PRESETS_FILE", tmp_path / ".presets.json")
|
||||
req = webapp.PresetRequest(id="Relief v2!", label=" Reliefs ",
|
||||
on=["slope", "aspect"],
|
||||
opacity={"slope": 0.5, "aspect": "0.8", "lrm": "x"},
|
||||
osm={"on": True, "opacity": 1.5, "dark": True})
|
||||
p = webapp._sanitize_preset(req)
|
||||
assert p["id"] == "reliefv2"
|
||||
assert p["label"] == "Reliefs"
|
||||
assert p["opacity"] == {"slope": 0.5, "aspect": 0.8}
|
||||
assert p["osm"] == {"on": True, "opacity": 1.0, "dark": True}
|
||||
webapp.upsert_preset(req)
|
||||
assert [x["label"] for x in webapp.list_presets()["presets"]] == ["Reliefs"]
|
||||
# Même identifiant : remplacement, pas de doublon
|
||||
webapp.upsert_preset(webapp.PresetRequest(id="reliefv2", label="Reliefs v2",
|
||||
on=["slope"], opacity={}))
|
||||
got = webapp.list_presets()["presets"]
|
||||
assert len(got) == 1 and got[0]["label"] == "Reliefs v2"
|
||||
# Suppression inconnue : 404
|
||||
from fastapi import HTTPException
|
||||
webapp.delete_preset(got[0]["id"])
|
||||
assert webapp.list_presets()["presets"] == []
|
||||
try:
|
||||
webapp.delete_preset("reliefv2")
|
||||
assert False, "une HTTPException était attendue"
|
||||
except HTTPException as e:
|
||||
assert e.status_code == 404
|
||||
|
||||
|
||||
def test_preset_file_corrupted_is_ignored(tmp_path, monkeypatch):
|
||||
"""Un fichier de presets corrompu est ignoré (liste vide, pas d'exception)."""
|
||||
import lidar_pipeline.webapp as webapp
|
||||
monkeypatch.setattr(webapp, "PRESETS_FILE", tmp_path / ".presets.json")
|
||||
webapp.PRESETS_FILE.write_text("{pas du json", encoding="utf-8")
|
||||
assert webapp._load_presets() == []
|
||||
|
||||
|
||||
def test_build_command_resolutions_match_completeness():
|
||||
"""La commande -r et la détection de complétude utilisent les mêmes résolutions."""
|
||||
from lidar_pipeline.webapp import GENERATE_RESOLUTIONS, _build_command
|
||||
|
||||
Reference in New Issue
Block a user