Run Black formatter across 83 files and fix 1514 ruff violations: - E722: bare except → typed exceptions (17 fixes) - E711/E712/E721: comparison style fixes with noqa for SQLAlchemy (44 fixes) - F841: unused variable assignments (70 fixes) - F541/F401: f-string and import cleanup (1383 auto-fixes) Remaining 925 errors are all F403/F405 (star imports) — structural, requires converting to explicit imports in a separate effort. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
72 lines
2.1 KiB
Python
72 lines
2.1 KiB
Python
from sqlmodel import Session, select
|
|
|
|
from in_game.gameplay_models import Game, Lineup, ManagerAi, Play
|
|
from in_game.managerai_responses import JumpResponse
|
|
|
|
|
|
def test_create_ai(session: Session):
|
|
all_ai = session.exec(select(ManagerAi)).all()
|
|
|
|
assert len(all_ai) == 3
|
|
assert ManagerAi.create_ai(session) is True
|
|
|
|
all_ai = session.exec(select(ManagerAi)).all()
|
|
|
|
assert len(all_ai) == 3
|
|
|
|
|
|
def test_check_jump(session: Session):
|
|
balanced_ai = session.exec(
|
|
select(ManagerAi).where(ManagerAi.name == "Balanced")
|
|
).one()
|
|
aggressive_ai = session.exec(
|
|
select(ManagerAi).where(ManagerAi.name == "Yolo")
|
|
).one()
|
|
|
|
this_game = session.get(Game, 1)
|
|
runner = session.get(Lineup, 5)
|
|
this_play = session.get(Play, 2)
|
|
|
|
this_play.on_first = runner
|
|
|
|
assert this_play.starting_outs == 1
|
|
assert balanced_ai.check_jump(session, this_game, to_base=2) == JumpResponse(
|
|
ai_note="- SEND **Player 4** to second if they get the jump", min_safe=16
|
|
)
|
|
assert aggressive_ai.check_jump(session, this_game, to_base=2) == JumpResponse(
|
|
ai_note="- SEND **Player 4** to second if they get the jump",
|
|
min_safe=13,
|
|
run_if_auto_jump=True,
|
|
)
|
|
|
|
this_play.on_third = runner
|
|
|
|
assert balanced_ai.check_jump(session, this_game, to_base=4) == JumpResponse(
|
|
min_safe=8
|
|
)
|
|
assert aggressive_ai.check_jump(session, this_game, to_base=4) == JumpResponse(
|
|
min_safe=5
|
|
)
|
|
|
|
|
|
def test_tag_from_second(session: Session):
|
|
balanced_ai = session.exec(
|
|
select(ManagerAi).where(ManagerAi.name == "Balanced")
|
|
).one()
|
|
aggressive_ai = session.exec(
|
|
select(ManagerAi).where(ManagerAi.name == "Yolo")
|
|
).one()
|
|
|
|
this_game = session.get(Game, 1)
|
|
runner = session.get(Lineup, 5)
|
|
this_play = session.get(Play, 2)
|
|
this_play.on_second = runner
|
|
|
|
assert this_play.starting_outs == 1
|
|
|
|
balanced_resp = balanced_ai.tag_from_second(session, this_game)
|
|
aggressive_resp = aggressive_ai.tag_from_second(session, this_game)
|
|
|
|
assert balanced_resp.min_safe == 5
|
|
assert aggressive_resp.min_safe == 2
|