124 lines
8.8 KiB
Python
124 lines
8.8 KiB
Python
import datetime
|
|
import pytest
|
|
from sqlmodel import Session, SQLModel, create_engine
|
|
from sqlmodel.pool import StaticPool
|
|
|
|
from typing import Literal
|
|
from in_game.gameplay_models import Game, Lineup, Team, Player
|
|
|
|
|
|
@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:
|
|
team_1 = Team(
|
|
id=31, abbrev='NCB', sname='CornBelters', lname='Normal CornBelters', gmid=1234, gmname='Cal', gsheet='asdf1234', wallet=6969, team_value=69420, collection_value=169420, color='006900', season=7, event=False, career=1234, ranking=1337, has_guide=True, is_ai=False
|
|
)
|
|
team_2 = Team(
|
|
id=400, abbrev='WV', sname='Black Bears', lname='West Virginia Black Bears', gmid=5678, gmname='Evil Cal', gsheet='https://i.postimg.cc/HjDc8bBF/blackbears-transparent.png', wallet=350, team_value=420, collection_value=169, color='6699FF', season=7, event=False, career=2, ranking=969, has_guide=False, is_ai=False
|
|
)
|
|
team_3 = Team(
|
|
id=69, abbrev='NCB3', sname='CornBelters', lname='Normal CornBelters', gmid=1234, gmname='Cal', gsheet='asdf1234', wallet=6969, team_value=69420, collection_value=169420, color='006900', season=7, event=False, career=1234, ranking=1337, has_guide=True, is_ai=False
|
|
)
|
|
team_4 = Team(
|
|
id=420, abbrev='WV4', sname='Black Bears', lname='West Virginia Black Bears', gmid=5678, gmname='Evil Cal', gsheet='https://i.postimg.cc/HjDc8bBF/blackbears-transparent.png', wallet=350, team_value=420, collection_value=169, color='6699FF', season=7, event=False, career=2, ranking=969, has_guide=False, is_ai=False
|
|
)
|
|
incomplete_team = Team(
|
|
id=446, abbrev='CLS', sname='Macho Men', lname='Columbus Macho Men', gmid=181818, gmname='Mason Socc', gsheet='asdf1234', wallet=6969, team_value=69420, collection_value=169420, color='https://i.postimg.cc/8kLZCYXh/S10CLS.png', season=7, event=False, career=0
|
|
)
|
|
old_cache_team = Team(
|
|
id=3, abbrev='BAL', sname='Orioles', lname='Baltimore Orioles', gmid=181818, gmname='Brandon Hyde', gsheet='asdf1234', wallet=6969, team_value=69420, collection_value=169420, color='https://i.postimg.cc/8kLZCYXh/S10CLS.png', season=7, event=False, career=0, ranking=500, has_guide=False, is_ai=False, created=datetime.datetime.today() - datetime.timedelta(days=60)
|
|
)
|
|
|
|
session.add(team_1)
|
|
session.add(team_2)
|
|
session.add(team_3)
|
|
session.add(team_4)
|
|
# session.add(incomplete_team)
|
|
session.add(old_cache_team)
|
|
session.commit()
|
|
|
|
game_1 = Game(away_team_id=1, home_team_id=2, channel_id=1234, season=9)
|
|
game_2 = Game(away_team_id=4, home_team_id=3, channel_id=5678, season=9, active=False, is_pd=True, 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')
|
|
game_3 = Game(away_team_id=3, home_team_id=4, channel_id=5678, season=9, active=True, is_pd=True, ranked=True, week_num=6, game_num=10, away_roster_id=69, home_roster_id=420, first_message=34567890, ai_team='home', game_type='minor-league')
|
|
|
|
session.add(game_1)
|
|
session.add(game_2)
|
|
session.add(game_3)
|
|
session.commit()
|
|
|
|
# all_lineups = []
|
|
# for team in [team_1, team_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, card_id=order, player_id=68+order, position=pos, batting_order=order, game=game_1))
|
|
# for team in [team_3, team_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, card_id=order, player_id=100+order, position=pos, batting_order=order, game=game_3))
|
|
|
|
yield session
|
|
|
|
|
|
@pytest.fixture(name='new_games')
|
|
def new_games_fixture():
|
|
return [
|
|
Game(away_team_id=1, home_team_id=2, channel_id=1234, season=9),
|
|
Game(away_team_id=4, home_team_id=3, channel_id=5678, season=9, active=False, is_pd=True, 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'),
|
|
Game(away_team_id=3, home_team_id=4, channel_id=5678, season=9, active=True, is_pd=True, ranked=True, week_num=6, game_num=10, away_roster_id=69, home_roster_id=420, first_message=34567890, ai_team='home', game_type='minor-league')
|
|
]
|
|
|
|
|
|
@pytest.fixture(name='new_games_with_lineups')
|
|
def new_games_with_lineups_fixture():
|
|
all_games = [
|
|
Game(away_team_id=1, home_team_id=2, channel_id=1234, season=9),
|
|
Game(away_team_id=4, home_team_id=3, channel_id=5678, season=9, active=False, is_pd=True, 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'),
|
|
Game(away_team_id=3, home_team_id=4, channel_id=5678, season=9, active=True, is_pd=True, ranked=True, week_num=6, game_num=10, away_roster_id=69, home_roster_id=420, first_message=34567890, ai_team='home', game_type='minor-league')
|
|
]
|
|
game_1 = all_games[0]
|
|
game_2 = all_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]
|
|
|
|
|
|
@pytest.fixture(name='new_teams')
|
|
def new_teams_fixture():
|
|
team_1 = Team(
|
|
id=31, abbrev='NCB', sname='CornBelters', lname='Normal CornBelters', gmid=1234, gmname='Cal', gsheet='asdf1234', wallet=6969, team_value=69420, collection_value=169420, color='006900', season=7, event=False, career=1234, ranking=1337, has_guide=True, is_ai=False
|
|
)
|
|
team_2 = Team(
|
|
id=400, abbrev='WV', sname='Black Bears', lname='West Virginia Black Bears', gmid=5678, gmname='Evil Cal', gsheet='https://i.postimg.cc/HjDc8bBF/blackbears-transparent.png', wallet=350, team_value=420, collection_value=169, color='6699FF', season=7, event=False, career=2, ranking=969, has_guide=False, is_ai=False
|
|
)
|
|
incomplete_team = Team(
|
|
id=446, abbrev='CLS', sname='Macho Men', lname='Columbus Macho Men', gmid=181818, gmname='Mason Socc', gsheet='asdf1234', wallet=6969, team_value=69420, collection_value=169420, color='https://i.postimg.cc/8kLZCYXh/S10CLS.png', season=7, event=False, career=0
|
|
)
|
|
old_cache_team = Team(
|
|
id=3, abbrev='BAL', sname='Orioles', lname='Baltimore Orioles', gmid=181818, gmname='Brandon Hyde', gsheet='asdf1234', wallet=6969, team_value=69420, collection_value=169420, color='https://i.postimg.cc/8kLZCYXh/S10CLS.png', season=7, event=False, career=0, ranking=500, has_guide=False, is_ai=False, created=datetime.datetime.today() - datetime.timedelta(days=60))
|
|
|
|
return [team_1, team_2, incomplete_team, old_cache_team]
|
|
|
|
|
|
@pytest.fixture(name='new_players')
|
|
def new_players_fixture():
|
|
player_1 = Player(
|
|
id=10139, name='Jihmih Tyranus', cost=316, image='https://pd.manticorum.com/api/v2/players/10139/battingcard?d=2024-5-07', mlbclub='Custom Ballplayers', franchise='Custom Ballplayers', set_num=420, pos_1='C', pos_2='3B', pos_3='LF', description='24 Custom', bbref_id='sandyman'
|
|
)
|
|
player_2 = Player(
|
|
id=9873, name='Finn Sturm', cost=146, image='https://pd.manticorum.com/api/v2/players/9873/battingcard?d=2024-5-06', mlbclub='Custom Ballplayers', franchise='Custom Ballplayers', set_num=69, pos_1='C', pos_2='1B', description='24 Custom', bbref_id='sandyman'
|
|
)
|
|
old_cache_player = Player(
|
|
id=10334, name='Ryan Ohearn', cost=91, image='https://pd.manticorum.com/api/v2/players/10334/battingcard?d=2024-8-18', mlbclub='Baltimore Orioles', franchise='Baltimore Orioles', set_num=420, pos_1='1B', pos_2='RF', pos_3='LF', description='2024', bbref_id='ohearry01', strat_code='656811', fangr_id='16442', mlbplayer_id=1200, created=datetime.datetime.today() - datetime.timedelta(days=60)
|
|
)
|
|
|
|
return [player_1, player_2, old_cache_player] |