FastAPI server, replaceable JSON config, tests, Dockerfile. Pairs with ATO via spec/interface.md contract. Co-authored-by: Cursor <cursoragent@cursor.com>
22 lines
555 B
Python
22 lines
555 B
Python
from trainsim.config_loader import SimParams
|
|
from trainsim.physics import Train
|
|
|
|
|
|
def test_train_accelerates_with_traction():
|
|
p = SimParams(1000, 20, 0.15, 0.25, 0.02, 25)
|
|
t = Train()
|
|
t.sim_running = True
|
|
t.actuate(100, 0)
|
|
for _ in range(120):
|
|
t.tick(p, 0.05)
|
|
assert t.speed_mps > 0.5
|
|
|
|
|
|
def test_brake_slows_train():
|
|
p = SimParams(1000, 20, 0.15, 0.25, 0.02, 25)
|
|
t = Train(speed_mps=10.0)
|
|
t.sim_running = True
|
|
t.actuate(0, 100)
|
|
for _ in range(200):
|
|
t.tick(p, 0.05)
|
|
assert t.speed_mps < 10.0
|