44 lines
1.6 KiB
Python
44 lines
1.6 KiB
Python
import pytest
|
|
from sqlmodel import Session, SQLModel, create_engine
|
|
from sqlmodel.pool import StaticPool
|
|
|
|
from typing import Literal
|
|
from in_game.gameplay_db import Game, Lineup
|
|
|
|
|
|
@pytest.fixture(name='session')
|
|
def session_fixture():
|
|
engine = create_engine(
|
|
'sqlite://', connect_args={'check_same_thread': False}, poolclass=StaticPool
|
|
)
|
|
SQLModel.metadata.create_all(engine)
|
|
with Session(engine) as session:
|
|
yield session
|
|
|
|
|
|
RAW_GAMES = [
|
|
Game(away_team_id=1, home_team_id=2, channel_id=1234, season=9),
|
|
Game(away_team_id=3, home_team_id=4, channel_id=5678, season=9, active=False, is_pd=False, ranked=True, week_num=6, game_num=9, away_roster_id=69, home_roster_id=420, first_message=12345678, ai_team='home', game_type='minor-league')
|
|
]
|
|
|
|
|
|
@pytest.fixture(name='new_games')
|
|
def new_games_fixture():
|
|
return RAW_GAMES
|
|
|
|
|
|
@pytest.fixture(name='new_games_with_lineups')
|
|
def new_games_with_lineups_fixture():
|
|
game_1 = RAW_GAMES[0]
|
|
game_2 = RAW_GAMES[1]
|
|
|
|
all_lineups = []
|
|
for team_id in [1, 2]:
|
|
for (order, pos) in [(1, 'C'), (2, '1B'), (3, '2B'), (4, '3B'), (5, 'SS'), (6, 'LF'), (7, 'CF'), (8, 'RF'), (9, 'DH'), (10, 'P')]:
|
|
all_lineups.append(Lineup(team_id=team_id, card_id=order, player_id=68+order, position=pos, batting_order=order, game=game_1))
|
|
|
|
for team_id in [3, 4]:
|
|
for (order, pos) in [(1, 'C'), (2, '1B'), (3, '2B'), (4, '3B'), (5, 'SS'), (6, 'LF'), (7, 'CF'), (8, 'RF'), (9, 'DH'), (10, 'P')]:
|
|
all_lineups.append(Lineup(team_id=team_id, card_id=order, player_id=100+order, position=pos, batting_order=order, game=game_2))
|
|
|
|
return [game_1, game_2] |