vercors.me : collecte Météo-France / Infoclimat / VP2, archive SQLite, accueil en carte, forum (squelette)
- collecte : collecter_meteofrance, extraire_infoclimat, extraire_vp2, archiver_historique, importer_opendata ; WeatherLink allégé (alleger) - tests : meteofrance, infoclimat, vp2, archive, opendata (tous verts) - maquettes/accueil-carte : sources de la maquette (générateurs de tuiles, page, À propos, CGU, confidentialité) - forum : noyau local (rôles, droits, SQLite, serveur de test, 18 tests) - deploy : Caddyfile.vercors.me.v2 (non appliqué) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cette révision appartient à :
1 Parent
956d08ffd7
révision
ff42faca16
42 fichiers modifiés
+5127
Aucun fichier ne correspond à votre recherche
@@ -0,0 +1,51 @@
|
||||
"""Tests de l'extraction VP2, sans réseau : python -I tests/test_vp2.py"""
|
||||
import datetime as dt
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "collecte"))
|
||||
import extraire_vp2 as vp # noqa: E402
|
||||
from collecter_weatherlink import verifier_public # noqa: E402
|
||||
|
||||
BASE = 1793779200 # 2026-11-04 08:00:00 UTC
|
||||
|
||||
|
||||
def l(ts, t=1.0, h=90.0, v=2.0, jour=0.0):
|
||||
return (BASE + ts, {"t": t, "h": h, "p": 1020.0, "v": v, "dir": 200.0, "jour": jour})
|
||||
|
||||
|
||||
def test_tranches_unites_pluie():
|
||||
lignes = [l(0, jour=1.0), l(20, jour=1.0), l(600, jour=1.4), l(1200, jour=1.4), l(1800, jour=1.8)]
|
||||
r = vp.releves(lignes)
|
||||
assert len(r) == 4 # une tranche de 10 minutes chacune
|
||||
assert r[-1]["vent_moyen"] == 7.2 and r[-1]["vent_direction"] == 200 # m/s -> km/h
|
||||
assert r[-1]["pluie_1h"] == 0.8 and r[-1]["pluie_cumul_0h"] == 1.8
|
||||
|
||||
|
||||
def test_remise_a_zero_minuit():
|
||||
r = vp.releves([l(0, jour=5.0), l(600, jour=0.2)])
|
||||
assert r[-1]["pluie_1h"] == 0.2 # cumul du jour reparti à zéro : on ne compte pas −4,8
|
||||
|
||||
|
||||
def test_point_de_rosee_et_hors_ligne():
|
||||
assert abs(vp.point_de_rosee(10.0, 100.0) - 10.0) < 0.01
|
||||
fin = dt.datetime.fromtimestamp(BASE + 7200, dt.timezone.utc)
|
||||
obj = vp.construire([l(0)], fin)
|
||||
assert obj["stations"]["lans"]["hors_ligne"] # dernier relevé vieux de 2 h
|
||||
verifier_public(obj)
|
||||
|
||||
|
||||
def test_aucune_donnee_interieure():
|
||||
obj = vp.construire([l(0)], dt.datetime.fromtimestamp(BASE + 60, dt.timezone.utc))
|
||||
texte = str(obj)
|
||||
assert "int" not in texte.replace("interieur", "") or "temp_int" not in texte
|
||||
assert set(obj["stations"]["lans"]["releves"][0]) <= {"dh_utc", "temperature", "humidite", "point_de_rosee", "pression",
|
||||
"vent_moyen", "vent_direction", "pluie_1h", "pluie_cumul_0h", "temperature_min", "temperature_max"}
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
n = 0
|
||||
for nom, f in list(globals().items()):
|
||||
if nom.startswith("test_") and callable(f):
|
||||
f(); n += 1
|
||||
print("%d tests OK" % n)
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur