diff --git a/tests/comparison_test.py b/tests/planning/test_comparison.py similarity index 52% rename from tests/comparison_test.py rename to tests/planning/test_comparison.py index 8d95c0a..a5fe73b 100644 --- a/tests/comparison_test.py +++ b/tests/planning/test_comparison.py @@ -26,6 +26,26 @@ def test_battery_energy_calculations(self): self.assertAlmostEqual(row["final_battery_energy_wh"], 3000.0) # 5000 * 0.6 = 3000 self.assertAlmostEqual(row["energy_margin_wh"], 1000.0) # (0.6-0.4) * 5000 = 1000 + def test_positive_margin(self): + car = CarConfig(battery_capacity=5000) + race = RaceConfig(target_soc=0.4) + results = SimpleNamespace( + total_laps=1, + total_distance_miles=1.0, + final_soc_pct=50.0, + min_soc_pct=20.0, + avg_speed_mph=10.0, + max_speed_mph=12.0, + min_speed_mph=8.0, + completed_full_window=True, + hit_min_soc=False, + ) + + row = build_comparison_row("fixed", race, car, results) + + self.assertGreater(row["soc_margin_pct"], 0) + self.assertGreater(row["energy_margin_wh"], 0) + def test_negative_margin(self): car = CarConfig(battery_capacity=5000) race = RaceConfig(target_soc=0.4) @@ -44,4 +64,24 @@ def test_negative_margin(self): row = build_comparison_row("fixed", race, car, results) self.assertLess(row["soc_margin_pct"], 0) - self.assertLess(row["energy_margin_wh"], 0) \ No newline at end of file + self.assertLess(row["energy_margin_wh"], 0) + + def test_zero_margin(self): + car = CarConfig(battery_capacity=5000) + race = RaceConfig(target_soc=0.4) + results = SimpleNamespace( + total_laps=1, + total_distance_miles=1.0, + final_soc_pct=40.0, + min_soc_pct=20.0, + avg_speed_mph=10.0, + max_speed_mph=12.0, + min_speed_mph=8.0, + completed_full_window=True, + hit_min_soc=False, + ) + + row = build_comparison_row("fixed", race, car, results) + + self.assertAlmostEqual(row["soc_margin_pct"], 0) + self.assertAlmostEqual(row["energy_margin_wh"], 0) \ No newline at end of file diff --git a/tests/csv_test.py b/tests/planning/test_csv.py similarity index 100% rename from tests/csv_test.py rename to tests/planning/test_csv.py diff --git a/tests/feasibility_test.py b/tests/planning/test_feasibility.py similarity index 78% rename from tests/feasibility_test.py rename to tests/planning/test_feasibility.py index ccc5d68..f69a28d 100644 --- a/tests/feasibility_test.py +++ b/tests/planning/test_feasibility.py @@ -40,3 +40,14 @@ def test_feasible_equal_soc(self): } self.assertTrue(check_feasibility(row)) + + def test_hit_min_soc(self): + row = { + "min_soc_pct": 40.0, + "final_soc_pct": 40.0, + "target_soc_pct": 50.0, + "completed_full_window": False, + "hit_min_soc": True + } + + self.assertFalse(check_feasibility(row)) diff --git a/tests/fixed_speed_sweep_test.py b/tests/planning/test_fixed_speed_sweep.py similarity index 100% rename from tests/fixed_speed_sweep_test.py rename to tests/planning/test_fixed_speed_sweep.py diff --git a/tests/scoring_test.py b/tests/planning/test_scoring.py similarity index 100% rename from tests/scoring_test.py rename to tests/planning/test_scoring.py