Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion tests/comparison_test.py → tests/planning/test_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
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)
File renamed without changes.
11 changes: 11 additions & 0 deletions tests/feasibility_test.py → tests/planning/test_feasibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
File renamed without changes.