From 3140226fa4d03f088f5d0996f95296cdfd76327d Mon Sep 17 00:00:00 2001 From: Aidan Liu Date: Sat, 17 Oct 2026 11:24:17 -0400 Subject: [PATCH 1/4] Positive and zero margin tests --- tests/comparison_test.py | 42 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/tests/comparison_test.py b/tests/comparison_test.py index 8d95c0a..a5fe73b 100644 --- a/tests/comparison_test.py +++ b/tests/comparison_test.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 From d6a05f7040578310125ab9947f1ab7bb8dd06a46 Mon Sep 17 00:00:00 2001 From: Aidan Liu Date: Sat, 17 Oct 2026 11:31:46 -0400 Subject: [PATCH 2/4] hit min soc test --- tests/feasibility_test.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/feasibility_test.py b/tests/feasibility_test.py index ccc5d68..f69a28d 100644 --- a/tests/feasibility_test.py +++ b/tests/feasibility_test.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)) From 2140dcdfbcb50f836ef37847631cb3af34ebc99e Mon Sep 17 00:00:00 2001 From: Aidan Liu Date: Sat, 17 Oct 2026 11:34:09 -0400 Subject: [PATCH 3/4] move all into separate folder --- tests/{ => planning}/comparison_test.py | 0 tests/{ => planning}/csv_test.py | 0 tests/{ => planning}/feasibility_test.py | 0 tests/{ => planning}/fixed_speed_sweep_test.py | 0 tests/{ => planning}/scoring_test.py | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename tests/{ => planning}/comparison_test.py (100%) rename tests/{ => planning}/csv_test.py (100%) rename tests/{ => planning}/feasibility_test.py (100%) rename tests/{ => planning}/fixed_speed_sweep_test.py (100%) rename tests/{ => planning}/scoring_test.py (100%) diff --git a/tests/comparison_test.py b/tests/planning/comparison_test.py similarity index 100% rename from tests/comparison_test.py rename to tests/planning/comparison_test.py diff --git a/tests/csv_test.py b/tests/planning/csv_test.py similarity index 100% rename from tests/csv_test.py rename to tests/planning/csv_test.py diff --git a/tests/feasibility_test.py b/tests/planning/feasibility_test.py similarity index 100% rename from tests/feasibility_test.py rename to tests/planning/feasibility_test.py diff --git a/tests/fixed_speed_sweep_test.py b/tests/planning/fixed_speed_sweep_test.py similarity index 100% rename from tests/fixed_speed_sweep_test.py rename to tests/planning/fixed_speed_sweep_test.py diff --git a/tests/scoring_test.py b/tests/planning/scoring_test.py similarity index 100% rename from tests/scoring_test.py rename to tests/planning/scoring_test.py From 94a0cd9f9d397f76dcafc83756de3dabc7659625 Mon Sep 17 00:00:00 2001 From: Aidan Liu Date: Sat, 17 Oct 2026 12:14:19 -0400 Subject: [PATCH 4/4] Rename to match other tests this also allows running all of the tests in this directory. neat! --- tests/planning/{comparison_test.py => test_comparison.py} | 0 tests/planning/{csv_test.py => test_csv.py} | 0 tests/planning/{feasibility_test.py => test_feasibility.py} | 0 .../{fixed_speed_sweep_test.py => test_fixed_speed_sweep.py} | 0 tests/planning/{scoring_test.py => test_scoring.py} | 0 5 files changed, 0 insertions(+), 0 deletions(-) rename tests/planning/{comparison_test.py => test_comparison.py} (100%) rename tests/planning/{csv_test.py => test_csv.py} (100%) rename tests/planning/{feasibility_test.py => test_feasibility.py} (100%) rename tests/planning/{fixed_speed_sweep_test.py => test_fixed_speed_sweep.py} (100%) rename tests/planning/{scoring_test.py => test_scoring.py} (100%) diff --git a/tests/planning/comparison_test.py b/tests/planning/test_comparison.py similarity index 100% rename from tests/planning/comparison_test.py rename to tests/planning/test_comparison.py diff --git a/tests/planning/csv_test.py b/tests/planning/test_csv.py similarity index 100% rename from tests/planning/csv_test.py rename to tests/planning/test_csv.py diff --git a/tests/planning/feasibility_test.py b/tests/planning/test_feasibility.py similarity index 100% rename from tests/planning/feasibility_test.py rename to tests/planning/test_feasibility.py diff --git a/tests/planning/fixed_speed_sweep_test.py b/tests/planning/test_fixed_speed_sweep.py similarity index 100% rename from tests/planning/fixed_speed_sweep_test.py rename to tests/planning/test_fixed_speed_sweep.py diff --git a/tests/planning/scoring_test.py b/tests/planning/test_scoring.py similarity index 100% rename from tests/planning/scoring_test.py rename to tests/planning/test_scoring.py