- rimossi scripts/, stadi.py, docs/USO.md, modelli non usati, partenze casuali, output ridondanti - uscita unica (report.md con grafici per dominio, risultati.json, proposta.png) - test: unitari su segnale sintetico, integrazione su dati/gen_*.csv (saltati se mancano) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
"""Lettura di config.toml e del CSV: errori attesi."""
|
|
|
|
import pytest
|
|
from conftest import RADICE
|
|
|
|
from fitseg import config, dati
|
|
|
|
|
|
def test_config_reale_valida():
|
|
assert config.leggi(RADICE / "config.toml")["dati"]["serie"] == ["T_C", "dT_C"]
|
|
|
|
|
|
def test_chiave_mancante(tmp_path):
|
|
(tmp_path / "c.toml").write_text("[dati]\ncolonna_tempo='t'\n")
|
|
with pytest.raises(config.ErroreConfig, match="chiavi mancanti"):
|
|
config.leggi(tmp_path / "c.toml")
|
|
|
|
|
|
def test_modelli_per_tipo_incompleto(tmp_path):
|
|
testo = (RADICE / "config.toml").read_text().replace('raffreddamento = ["esp_decad"]', "raffreddamento = []")
|
|
(tmp_path / "c.toml").write_text(testo)
|
|
with pytest.raises(config.ErroreConfig, match="raffreddamento"):
|
|
config.leggi(tmp_path / "c.toml")
|
|
|
|
|
|
def test_config_inesistente():
|
|
with pytest.raises(config.ErroreConfig, match="impossibile leggere"):
|
|
config.leggi("/non/esiste.toml")
|
|
|
|
|
|
def test_csv_valido(cfg, tmp_path):
|
|
(tmp_path / "d.csv").write_text("t_ms,T_C,dT_C\n100,20.0,0.1\n250,20.1,0.2\n")
|
|
t, serie = dati.leggi_csv(tmp_path / "d.csv", cfg)
|
|
assert t.tolist() == [0.1, 0.25] and serie["T_C"].tolist() == [20.0, 20.1]
|
|
|
|
|
|
def test_csv_colonna_mancante(cfg, tmp_path):
|
|
(tmp_path / "d.csv").write_text("t_ms,T_C\n100,20.0\n")
|
|
with pytest.raises(dati.ErroreDati, match="dT_C"):
|
|
dati.leggi_csv(tmp_path / "d.csv", cfg)
|
|
|
|
|
|
def test_csv_tempo_non_crescente(cfg, tmp_path):
|
|
(tmp_path / "d.csv").write_text("t_ms,T_C,dT_C\n200,20,0\n100,20,0\n")
|
|
with pytest.raises(dati.ErroreDati, match="crescente"):
|
|
dati.leggi_csv(tmp_path / "d.csv", cfg)
|