fix: update tests to match current algorithm — thresholds, _best_climb tuples, ComputedMetrics fields
CI / Python tests (push) Waiting to run
CI / Frontend build (push) Waiting to run

This commit is contained in:
Davide Scaini
2026-06-03 22:18:17 +02:00
parent f167c6eed7
commit 060bdf5114
4 changed files with 36 additions and 29 deletions
+5 -5
View File
@@ -73,25 +73,25 @@ class TestHysteresisEndpoint:
assert "elevation_loss_m" in body
assert body["elevation_gain_m"] > 0
assert body["altitude_source"] == "barometric"
assert body["threshold_m"] == pytest.approx(1.0)
assert body["threshold_m"] == pytest.approx(1.5)
def test_gps_source_uses_3m_threshold(self, tmp_path):
def test_gps_source_uses_2m_threshold(self, tmp_path):
elevations = [float(i) for i in range(1801)]
_make_activity(tmp_path, self.AID, elevations, altitude_source="gps")
r = CLIENT.post(f"/api/activity/{self.AID}/recalculate-elevation/hysteresis")
assert r.status_code == 200
assert r.json()["threshold_m"] == pytest.approx(3.0)
assert r.json()["threshold_m"] == pytest.approx(2.0)
def test_unknown_source_falls_back_to_gps_threshold(self, tmp_path):
def test_unknown_source_uses_1_5m_threshold(self, tmp_path):
elevations = [float(i) for i in range(1801)]
_make_activity(tmp_path, self.AID, elevations, altitude_source="unknown")
r = CLIENT.post(f"/api/activity/{self.AID}/recalculate-elevation/hysteresis")
assert r.status_code == 200
assert r.json()["threshold_m"] == pytest.approx(3.0)
assert r.json()["threshold_m"] == pytest.approx(1.5)
def test_uses_original_elevation_when_dem_backup_present(self, tmp_path):
original = [float(i) for i in range(1801)] # real 1800 m climb