def test_flagrant_free_throw_type(): foul = { "EVENTNUM": 609, "PCTIMESTRING": "0:25", "VISITORDESCRIPTION": "Griffin Flagrant Foul (P5.PN) (M.Davis)", "EVENTMSGACTIONTYPE": 14, "EVENTMSGTYPE": 6, "PLAYER1_ID": 201933, "PLAYER1_TEAM_ID": 1610612765, "PLAYER2_ID": 203078, "PLAYER2_TEAM_ID": 1610612764, "PLAYER3_ID": None, "PLAYER3_TEAM_ID": None, } order = 1 foul_event = StatsFoul(foul, order) ft_1_of_2 = { "EVENTNUM": 611, "PCTIMESTRING": "0:25", "HOMEDESCRIPTION": "Beal Free Throw Flagrant 1 of 2 (32 PTS)", "EVENTMSGACTIONTYPE": 11, "EVENTMSGTYPE": 3, "PLAYER1_ID": 203078, "PLAYER1_TEAM_ID": 1610612764, "PLAYER2_ID": None, "PLAYER2_TEAM_ID": None, "PLAYER3_ID": None, "PLAYER3_TEAM_ID": None, } order = 1 ft_1_of_2_event = StatsFreeThrow(ft_1_of_2, order) ft_2_of_2 = { "EVENTNUM": 611, "PCTIMESTRING": "0:25", "HOMEDESCRIPTION": "Beal Free Throw Flagrant 2 of 2 (32 PTS)", "EVENTMSGACTIONTYPE": 12, "EVENTMSGTYPE": 3, "PLAYER1_ID": 203078, "PLAYER1_TEAM_ID": 1610612764, "PLAYER2_ID": None, "PLAYER2_TEAM_ID": None, "PLAYER3_ID": None, "PLAYER3_TEAM_ID": None, } order = 1 ft_2_of_2_event = StatsFreeThrow(ft_2_of_2, order) foul_event.previous_event = None foul_event.next_event = ft_1_of_2_event ft_1_of_2_event.previous_event = foul_event ft_1_of_2_event.next_event = ft_2_of_2_event ft_2_of_2_event.previous_event = ft_1_of_2_event ft_2_of_2_event.next_event = None assert ft_1_of_2_event.free_throw_type == "2 Shot Flagrant"
def test_event_for_efficiency_stats_when_events_out_of_order(): ft = { "EVENTMSGTYPE": 3, "EVENTMSGACTIONTYPE": 10, "HOMEDESCRIPTION": "Free Throw 1 of 1", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 1, "PLAYER1_ID": 1, } order = 1 ft_event = StatsFreeThrow(ft, order) foul = { "EVENTMSGTYPE": 6, "EVENTMSGACTIONTYPE": 6, "VISITORDESCRIPTION": "Away From Play Foul", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 2, "PLAYER1_ID": 2, "PLAYER2_ID": 1, } order = 1 foul_event = StatsFoul(foul, order) ft_event.previous_event = None ft_event.next_event = foul_event foul_event.previous_event = ft_event foul_event.next_event = None assert ft_event.event_for_efficiency_stats == foul_event
def test_is_make_that_does_not_end_possession_with_foul_out_of_order_true(): make = { "EVENTMSGTYPE": 1, "EVENTMSGACTIONTYPE": 10, "PLAYER1_ID": 15, "PLAYER1_TEAM_ID": 1, "HOMEDESCRIPTION": "Made Shot", "PCTIMESTRING": "0:45", "EVENTNUM": 1, } order = 1 make_event = StatsFieldGoal(make, order) ft = { "EVENTMSGTYPE": 3, "EVENTMSGACTIONTYPE": 10, "HOMEDESCRIPTION": "Free Throw 1 of 1", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 1, "PLAYER1_ID": 15, "EVENTNUM": 2, } order = 1 ft_event = StatsFreeThrow(ft, order) foul = { "EVENTMSGTYPE": 6, "EVENTMSGACTIONTYPE": 2, "VISITORDESCRIPTION": "Shooting Foul", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 2, "PLAYER1_ID": 12, "PLAYER2_ID": 15, "EVENTNUM": 3, } order = 1 foul_event = StatsFoul(foul, order) make_event.previous_event = None make_event.next_event = ft_event ft_event.previous_event = make_event ft_event.next_event = foul_event foul_event.previous_event = ft_event foul_event.next_event = None assert make_event.is_make_that_does_not_end_possession is True
def test_foul_on_made_shot_by_team_that_didnt_get_fouled_is_away_from_play_ft( ): ft = { "EVENTMSGTYPE": 3, "EVENTMSGACTIONTYPE": 10, "HOMEDESCRIPTION": "Free Throw 1 of 1", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 1, "PLAYER1_ID": 1, } order = 1 ft_event = StatsFreeThrow(ft, order) foul = { "EVENTMSGTYPE": 6, "EVENTMSGACTIONTYPE": 6, "VISITORDESCRIPTION": "Away From Play Foul", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 2, "PLAYER1_ID": 2, "PLAYER2_ID": 1, } order = 1 foul_event = StatsFoul(foul, order) make = { "EVENTMSGTYPE": 1, "EVENTMSGACTIONTYPE": 10, "HOMEDESCRIPTION": "Made Shot by team that got fouled", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 2, "PLAYER1_ID": 3, } order = 1 make_event = StatsFieldGoal(make, order) ft_event.previous_event = None ft_event.next_event = foul_event foul_event.previous_event = ft_event foul_event.next_event = make_event make_event.previous_event = foul_event make_event.next_event = None assert ft_event.is_away_from_play_ft is True
def test_away_from_play_free_throw_type(): foul = { "EVENTMSGTYPE": 6, "EVENTMSGACTIONTYPE": 6, "VISITORDESCRIPTION": "Away From Play Foul", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 2, "PLAYER1_ID": 2, "PLAYER2_ID": 1, } order = 1 foul_event = StatsFoul(foul, order) ft = { "EVENTMSGTYPE": 3, "EVENTMSGACTIONTYPE": 10, "HOMEDESCRIPTION": "Free Throw 1 of 1", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 1, "PLAYER1_ID": 1, } order = 1 ft_event = StatsFreeThrow(ft, order) make = { "EVENTMSGTYPE": 1, "EVENTMSGACTIONTYPE": 10, "VISITORDESCRIPTION": "Made Shot by team that got fouled", "PCTIMESTRING": "0:35", "PLAYER1_TEAM_ID": 1, "PLAYER1_ID": 21, } order = 1 make_event = StatsFieldGoal(make, order) foul_event.previous_event = None foul_event.next_event = ft_event ft_event.previous_event = foul_event ft_event.next_event = make_event make_event.previous_event = ft_event make_event.next_event = None assert ft_event.free_throw_type == "1 Shot Away From Play"
def test_inbound_foul_ft_true(): foul = { "EVENTMSGTYPE": 6, "EVENTMSGACTIONTYPE": 5, "VISITORDESCRIPTION": "Inbound Foul", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 2, } order = 1 foul_event = StatsFoul(foul, order) ft = { "EVENTMSGTYPE": 3, "EVENTMSGACTIONTYPE": 10, "HOMEDESCRIPTION": "Free Throw 1 of 1", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 1, } order = 1 ft_event = StatsFreeThrow(ft, order) foul_event.previous_event = None foul_event.next_event = ft_event ft_event.previous_event = foul_event ft_event.next_event = None assert ft_event.is_inbound_foul_ft is True
def test_foul_on_made_ft_by_team_that_didnt_get_fouled_is_away_from_play_ft(): ft_2_of_2 = { "EVENTNUM": 607, "PCTIMESTRING": "0:25", "VISITORDESCRIPTION": "Jackson Free Throw 2 of 2 (16 PTS)", "EVENTMSGACTIONTYPE": 12, "EVENTMSGTYPE": 3, "PLAYER1_ID": 202704, "PLAYER1_TEAM_ID": 1610612765, "PLAYER2_ID": None, "PLAYER2_TEAM_ID": None, "PLAYER3_ID": None, "PLAYER3_TEAM_ID": None, } order = 1 ft_2_of_2_event = StatsFreeThrow(ft_2_of_2, order) foul = { "EVENTNUM": 609, "PCTIMESTRING": "0:25", "VISITORDESCRIPTION": "Griffin AWAY.FROM.PLAY.FOUL (P5.PN) (M.Davis)", "EVENTMSGACTIONTYPE": 6, "EVENTMSGTYPE": 6, "PLAYER1_ID": 201933, "PLAYER1_TEAM_ID": 1610612765, "PLAYER2_ID": 201145, "PLAYER2_TEAM_ID": 1610612764, "PLAYER3_ID": None, "PLAYER3_TEAM_ID": None, } order = 1 foul_event = StatsFoul(foul, order) ft_1_of_1 = { "EVENTNUM": 611, "PCTIMESTRING": "0:25", "HOMEDESCRIPTION": "Beal Free Throw 1 of 1 (32 PTS)", "EVENTMSGACTIONTYPE": 10, "EVENTMSGTYPE": 3, "PLAYER1_ID": 203078, "PLAYER1_TEAM_ID": 1610612764, "PLAYER2_ID": None, "PLAYER2_TEAM_ID": None, "PLAYER3_ID": None, "PLAYER3_TEAM_ID": None, } order = 1 ft_1_of_1_event = StatsFreeThrow(ft_1_of_1, order) fg = { "EVENTNUM": 612, "PCTIMESTRING": "0:24", "VISITORDESCRIPTION": "MISS Green 27' 3PT Jump Shot", "EVENTMSGACTIONTYPE": 1, "EVENTMSGTYPE": 2, "PLAYER1_ID": 201145, "PLAYER1_TEAM_ID": 1610612764, "PLAYER2_ID": None, "PLAYER2_TEAM_ID": None, "PLAYER3_ID": None, "PLAYER3_TEAM_ID": None, } order = 1 fg_event = StatsFieldGoal(fg, order) ft_2_of_2_event.previous_event = None ft_2_of_2_event.next_event = foul_event foul_event.previous_event = ft_2_of_2_event foul_event.next_event = ft_1_of_1_event ft_1_of_1_event.previous_event = foul_event ft_1_of_1_event.next_event = fg_event fg_event.previous_event = ft_1_of_1_event fg_event.next_event = None assert ft_1_of_1_event.is_away_from_play_ft is True
def test_is_make_that_does_not_end_possession_shot_at_time_of_and1_ft_is_false( ): make = { "EVENTMSGTYPE": 1, "EVENTMSGACTIONTYPE": 10, "PLAYER1_ID": 15, "PLAYER1_TEAM_ID": 1, "HOMEDESCRIPTION": "Made Shot", "PCTIMESTRING": "0:45", "EVENTNUM": 1, } order = 1 make_event = StatsFieldGoal(make, order) foul = { "EVENTMSGTYPE": 6, "EVENTMSGACTIONTYPE": 2, "VISITORDESCRIPTION": "Shooting Foul", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 2, "PLAYER1_ID": 12, "PLAYER2_ID": 15, "EVENTNUM": 2, } order = 1 foul_event = StatsFoul(foul, order) ft = { "EVENTMSGTYPE": 3, "EVENTMSGACTIONTYPE": 10, "HOMEDESCRIPTION": "Free Throw 1 of 1", "PCTIMESTRING": "0:45", "PLAYER1_TEAM_ID": 1, "PLAYER1_ID": 15, "EVENTNUM": 3, } order = 1 ft_event = StatsFreeThrow(ft, order) rebound = { "EVENTMSGTYPE": 4, "EVENTMSGACTIONTYPE": 0, "PLAYER1_ID": 17, "PLAYER1_TEAM_ID": 1, "HOMEDESCRIPTION": "Rebound", "PCTIMESTRING": "0:45", "EVENTNUM": 4, } order = 2 rebound_event = StatsRebound(rebound, order) tip = { "EVENTMSGTYPE": 1, "EVENTMSGACTIONTYPE": 10, "PLAYER1_ID": 17, "PLAYER1_TEAM_ID": 1, "HOMEDESCRIPTION": "Made Shot", "PCTIMESTRING": "0:45", "EVENTNUM": 5, } order = 1 tip_event = StatsFieldGoal(tip, order) make_event.previous_event = None make_event.next_event = foul_event foul_event.previous_event = make_event foul_event.next_event = ft_event ft_event.previous_event = foul_event ft_event.next_event = rebound_event rebound_event.previous_event = ft_event rebound_event.next_event = tip_event tip_event.previous_event = rebound_event tip_event.next_event = None assert make_event.is_make_that_does_not_end_possession is True assert tip_event.is_make_that_does_not_end_possession is False