paper-dynasty-discord/tests/gameplay_models/test_play_model.py
Cal Corum ee685f1415 Updated scorebug embed
Added play initialization
2024-10-24 17:14:11 -05:00

43 lines
1.0 KiB
Python

from sqlmodel import Session, select
from in_game.gameplay_models import Lineup, Play, Game
from factory import session_fixture
def test_create_play(session: Session):
all_plays = session.exec(select(Play)).all()
assert len(all_plays) == 2
play_1 = session.get(Play, 1)
assert play_1.game_id == 1
assert play_1.pa == 1
assert play_1.pitcher_id == 20
def test_get_current_play(session: Session):
game_1 = session.get(Game, 1)
curr_play = game_1.current_play_or_none(session)
assert curr_play.play_num == 2
def test_scorebug_ascii(session: Session):
new_play = Play(
game_id=3,
play_num=69,
batter=session.get(Lineup, 1),
batter_pos='DH',
pitcher=session.get(Lineup, 20),
catcher=session.get(Lineup, 11),
starting_outs=1,
inning_num=6
)
session.add(new_play)
session.commit()
assert new_play.scorebug_ascii == '```\nNCB3 0 ○ ▲ 6\n WV4 0 ○ ○ 1 Out\n```'
# TODO: test get_ai_note