Skip to content

Commit

Permalink
Two tests to fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBrostoff committed Dec 27, 2023
1 parent 8fc51e5 commit 9907114
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 29 deletions.
26 changes: 13 additions & 13 deletions draftfast/test/test_custom_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

def construct_pool():
mock_nba_pool = [
Player(name="A1", cost=5500, proj=100, pos="PG"),
Player(name="A2", cost=5500, proj=41, pos="PG"),
Player(name="A100", cost=5500, proj=501, pos="PG"),
Player(name="A101", cost=5500, proj=500, pos="PG"),
Player(name="A11", cost=5500, proj=50, pos="PG"),
Player(name="A3", cost=5500, proj=42, pos="SG"),
Player(name="A4", cost=5500, proj=0, pos="SG"),
Player(name="A5", cost=5500, proj=44, pos="SF"),
Player(name="A6", cost=5500, proj=45, pos="SF"),
Player(name="A7", cost=5500, proj=46, pos="PF"),
Player(name="A8", cost=5500, proj=47, pos="PF"),
Player(name="A9", cost=5500, proj=0, pos="C"),
Player(name="A10", cost=5500, proj=49, pos="C"),
Player(name="A1", cost=5500, proj=100, pos="PG", matchup='AvB'),
Player(name="A2", cost=5500, proj=41, pos="PG", matchup='AvB'),
Player(name="A100", cost=5500, proj=501, pos="PG", matchup='AvB'),
Player(name="A101", cost=5500, proj=500, pos="PG", matchup='AvB'),
Player(name="A11", cost=5500, proj=50, pos="PG", matchup='AvB'),
Player(name="A3", cost=5500, proj=42, pos="SG", matchup='AvB'),
Player(name="A4", cost=5500, proj=0, pos="SG", matchup='CvD'),
Player(name="A5", cost=5500, proj=44, pos="SF", matchup='CvD'),
Player(name="A6", cost=5500, proj=45, pos="SF", matchup='CvD'),
Player(name="A7", cost=5500, proj=46, pos="PF", matchup='CvD'),
Player(name="A8", cost=5500, proj=47, pos="PF", matchup='CvD'),
Player(name="A9", cost=5500, proj=0, pos="C", matchup='CvD'),
Player(name="A10", cost=5500, proj=49, pos="C", matchup='CvD'),
]

team = 0
Expand Down
38 changes: 22 additions & 16 deletions draftfast/test/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ def test_multi_position_group_constraint():
pos="QB",
possible_positions="QB/WR",
multi_position=True,
matchup='AvB',
),
Player(
name="A",
Expand All @@ -562,15 +563,17 @@ def test_multi_position_group_constraint():
pos="WR",
possible_positions="QB/WR",
multi_position=True,
matchup='CvD',
),
Player(name="B", cost=5500, proj=41, pos="QB"),
Player(name="B", cost=5500, proj=41, pos="QB", matchup='AvB'),
Player(
name="C",
cost=5500,
proj=500,
pos="WR",
possible_positions="RB/WR",
multi_position=True,
matchup='AvB',
),
Player(
name="C",
Expand All @@ -579,20 +582,22 @@ def test_multi_position_group_constraint():
pos="RB",
possible_positions="RB/WR",
multi_position=True,
),
Player(name="D", cost=5500, proj=42, pos="WR"),
Player(name="E", cost=5500, proj=43, pos="WR"),
Player(name="F", cost=5500, proj=44, pos="WR"),
Player(name="G", cost=5500, proj=45, pos="RB"),
Player(name="H", cost=5500, proj=46, pos="RB"),
Player(name="I", cost=5500, proj=47, pos="RB"),
matchup='AvB',
),
Player(name="D", cost=5500, proj=42, pos="WR", matchup='AvB'),
Player(name="E", cost=5500, proj=43, pos="WR", matchup='AvB'),
Player(name="F", cost=5500, proj=44, pos="WR", matchup='AvB'),
Player(name="G", cost=5500, proj=45, pos="RB", matchup='AvB'),
Player(name="H", cost=5500, proj=46, pos="RB", matchup='AvB'),
Player(name="I", cost=5500, proj=47, pos="RB", matchup='AvB'),
Player(
name="J",
cost=5500,
proj=480,
pos="TE",
possible_positions="TE/WR",
multi_position=True,
matchup='AvB',
),
Player(
name="J",
Expand All @@ -601,10 +606,11 @@ def test_multi_position_group_constraint():
pos="WR",
possible_positions="TE/WR",
multi_position=True,
matchup='AvB',
),
Player(name="K", cost=5500, proj=49, pos="TE"),
Player(name="L", cost=5500, proj=51, pos="DST"),
Player(name="M", cost=5500, proj=52, pos="DST"),
Player(name="K", cost=5500, proj=49, pos="TE", matchup='CvD'),
Player(name="L", cost=5500, proj=51, pos="DST", matchup='CvD'),
Player(name="M", cost=5500, proj=52, pos="DST", matchup='CvD'),
]

grouped_players = ("A", "C", "J")
Expand Down Expand Up @@ -719,12 +725,12 @@ def test_no_opposing_def_dk_nfl_mock():
]

# relax min teams for simplified player pool
rules.DK_NFL_RULE_SET.min_teams = 1
rules.DK_NFL_RULE_SET.min_matchups = 1
# mock pool is constructed such that optimal lineup has qb opposing dst
roster = run(
rule_set=rules.DK_NFL_RULE_SET, player_pool=mock_pool, verbose=True
)
rules.DK_NFL_RULE_SET.min_teams = 3
rules.DK_NFL_RULE_SET.min_matchups = 2

assertions.assertEqual(roster.projected(), 909)
qb_team = roster.sorted_players()[0].team
Expand All @@ -741,7 +747,7 @@ def test_no_opposing_def_dk_nfl_mock():

assertions.assertEqual(roster, None)

rules.DK_NFL_RULE_SET.min_teams = 1
rules.DK_NFL_RULE_SET.min_matchups = 1
roster = run(
rule_set=rules.DK_NFL_RULE_SET,
player_pool=mock_pool,
Expand All @@ -754,7 +760,7 @@ def test_no_opposing_def_dk_nfl_mock():
assertions.assertEqual(roster.projected(), 877)
assertions.assertEqual(len(set([p.team for p in roster.players])), 1)

# add a player from a third team, min 2 teams
# add a player from a second matchup, min two matchups
mock_pool.append(
Player(
name="B2", cost=5500, proj=70, pos="QB", team="Q", matchup="Q@Z"
Expand All @@ -771,7 +777,7 @@ def test_no_opposing_def_dk_nfl_mock():
if p.pos in rules.DK_NFL_RULE_SET.offensive_positions:
assertions.assertNotEqual(p.team, "X")

rules.DK_NFL_RULE_SET.min_teams = 3
rules.DK_NFL_RULE_SET.min_matchups = 2


def test_no_opposing_def_dk_nfl():
Expand Down

0 comments on commit 9907114

Please sign in to comment.