Skip to content

Commit

Permalink
Working on test
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBrostoff committed Jan 25, 2024
1 parent fcc4d18 commit eec49ac
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
18 changes: 6 additions & 12 deletions draftfast/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,24 @@ def run(

if verbose:
print(
"""
f"""
No solution found.
Try adjusting your query by taking away constraints.
OPTIMIZER CONSTRAINTS:
{}
{optimizer_settings}
LINEUP CONSTRAINTS:
{}
{constraints}
PLAYER POOL SETTINGS:
{}
{players}
PLAYER COUNT: {}
""".format(
optimizer_settings,
constraints,
player_settings,
len(players or []),
)
)
PLAYER COUNT: {len(players or [])}
""")
return None


Expand Down
27 changes: 27 additions & 0 deletions draftfast/test/test_nhl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,33 @@ def test_nhl_dk():
)
assertions.assertNotEqual(roster, None)

def test_nhl_dk_unsolvable_three_team_non_goalie_restriction():
"""
Should not solve if unable to get min teams of 3
not including goalie team
"""
player_pool = salary_download.generate_players_from_csvs(
salary_file_location=salary_file,
game=rules.DRAFT_KINGS,
ruleset=rules.DK_NHL_RULE_SET,
)
unique_teams = set()
new_player_pool = []
for p in player_pool:
if p.pos != 'G':
unique_teams.add(p.team)
if len(unique_teams) > 2 and p.team not in unique_teams:
continue

new_player_pool.append(p)

roster = run(
rule_set=rules.DK_NHL_RULE_SET,
player_pool=new_player_pool,
verbose=True,
)
assertions.assertEqual(roster, None)


def test_triple_stack():
player_pool = salary_download.generate_players_from_csvs(
Expand Down

0 comments on commit eec49ac

Please sign in to comment.