def test_unicode_names_invalid_type(self, replay_cache): def test(analysis: AnalysisManager): with NamedTemporaryFile(mode='w') as f: with pytest.raises(IOError): analysis.write_pandas_out_to_file(f) run_analysis_test_on_replay(test, get_raw_replays()["UNICODE_ERROR"], cache=replay_cache)
def test_hit_pressure(self, replay_cache): def test(analysis: AnalysisManager, answer): proto_game = analysis.get_protobuf_data() hits = proto_game.game_stats.hits expected_pressures = [ 100, 100, 100, 100, 0, 93, 100, 100, 94, 0, 0, 95, 100, 100, 0, 0, 0, 0, 90, 0, 0, 94, 100, 100, 0, 99, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 99, 100, 0, 0, 0, 0, 100, 100, 100, 0, 100, 0, 0, 0, 0, 100, 100, 100, 100, 0, 100, 0, 94, 0, 96, 0, 100, 100, 100, 0, 0, 0, 0, 0, 98, 100, 0, 0, 100, 100, 0, 100, 0, 0, 0, 100, 100, 0, 0, 100, 0, 94, 100, 72, 100, 100, 0, 0, 0, 100, 100, 100, 100, 100, 100, 0, 0, 0, 0, 0, 0, 0, 94, 0, 100, 97, 100, 100, 0, 100, 0, 0, 0, 0, 0, 81, 100, 97, 100, 81, 100, 0, 100, 100, 0, 100, 100, 100, 100, 91, 0, 0, 0, 100, 0, 96, 100, 100, 99, 0, 0, 0, 100, 0, 0, 0, 0, 0, 100, 0, 99, 100, 98, 0, 94, 0, 100, 0, 100, 100, 0, 100, 100, 100, 0, 100, 0, 100, 67, 0, 91, 100, 100, 100, 0, 0, 0, 0, 88, 0, 100, 0, 100, 0, 0 ] for x in range(len(hits)): assert (hits[x].pressure == expected_pressures[x]) # Skip test cache since this test is calculating intensive events. run_analysis_test_on_replay( test, replay_list=get_raw_replays()["OCE_RLCS_7_CARS"], answers=get_specific_answers()["CLEARS"], calculate_intensive_events=True)
def test_proto_export_invalid_type(self, replay_cache): def test(analysis: AnalysisManager): with NamedTemporaryFile(mode='w') as f: with pytest.raises(IOError): analysis.write_proto_out_to_file(f) run_analysis_test_on_replay(test, get_raw_replays()["DEFAULT_3_ON_3_AROUND_58_HITS"], cache=replay_cache)
def test_all_kickoffs_2(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() kickoffs = proto_game.game_stats.kickoffs assert (len(kickoffs) == 6) first_player = proto_game.players[0].stats kickoff_stats = first_player.kickoff_stats assert kickoff_stats.num_time_first_touch == 1 assert kickoff_stats.num_time_go_to_ball == 1 assert kickoff_stats.num_time_boost == 1 assert kickoff_stats.num_time_cheat == 0 assert kickoff_stats.num_time_defend == 1 assert kickoff_stats.num_time_afk == 1 assert kickoff_stats.total_kickoffs == 6 assert 2 == ( kickoff_stats.total_kickoffs - (kickoff_stats.num_time_go_to_ball + kickoff_stats.num_time_boost + kickoff_stats.num_time_cheat + kickoff_stats.num_time_defend + kickoff_stats.num_time_afk)) second_player_stats = proto_game.players[1].stats.kickoff_stats assert second_player_stats.num_time_first_touch == 5 assert second_player_stats.num_time_go_to_ball == 6 for i in range(len(kickoffs)): kickoff = proto_game.game_stats.kickoff_stats[i] player = kickoff.touch.players[0] start_left = player.start_position.pos_x < 0 assert player.start_left == start_left run_analysis_test_on_replay(test, get_raw_replays()["6_DIVERSE_KICKOFFS"])
def test_3_kickoffs(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() kickoffs = proto_game.game_stats.kickoffs self.assertEqual(len(kickoffs), 3) run_analysis_test_on_replay(test, get_raw_replays()["3_KICKOFFS"])
def test_json_export(self, replay_cache): def test(analysis: AnalysisManager): with NamedTemporaryFile(mode='w') as f: analysis.write_json_out_to_file(f) run_analysis_test_on_replay( test, get_raw_replays()["DEFAULT_3_ON_3_AROUND_58_HITS"], cache=replay_cache)
def test_zero_dribbles(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() carries = proto_game.game_stats.ball_carries assert (len(carries) == 0) run_analysis_test_on_replay(test, get_raw_replays()["KICKOFF_NO_TOUCH"], cache=replay_cache)
def test_dribble_detection_is_zero(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() carries = proto_game.game_stats.ball_carries assert (len(carries) == 0) run_analysis_test_on_replay(test, get_specific_replays()["ZERO_DRIBBLE"], cache=replay_cache)
def test_0_kickoffs(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() kickoffs = proto_game.game_stats.kickoffs assert (len(kickoffs) == 0) run_analysis_test_on_replay(test, get_raw_replays()["KICKOFF_NO_TOUCH"])
def test_no_one_for_kickoffs(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() kickoffs = proto_game.game_stats.kickoffs assert (len(kickoffs) == 1) run_analysis_test_on_replay(test, get_raw_replays()["NO_ONE_FOR_KICKOFF"])
def test_calculate_demos_correctly(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() bumps = proto_game.game_stats.bumps assert len(bumps) == 1 run_analysis_test_on_replay(test, get_raw_replays()["1_DEMO"], cache=replay_cache)
def test_boost_steals(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() player = proto_game.players[0] boost = player.stats.boost assert boost.num_stolen_boosts == 2 run_analysis_test_on_replay(test, get_raw_replays()["6_BIG_25_SMALL"], cache=replay_cache)
def test_num_hits_detected(self): def test(analysis: AnalysisManager, answer): proto_game = analysis.get_protobuf_data() hits = proto_game.game_stats.hits self.assertEqual(len(hits), answer) print(analysis) run_analysis_test_on_replay(test, get_specific_replays()["HITS"], get_specific_answers()["HITS"])
def test_gzip_export(self, replay_cache): def test(analysis: AnalysisManager): with NamedTemporaryFile(mode='wb') as f: gzip_file = gzip.GzipFile(mode='wb', fileobj=f) analysis.write_pandas_out_to_file(gzip_file) run_analysis_test_on_replay( test, get_raw_replays()["DEFAULT_3_ON_3_AROUND_58_HITS"], cache=replay_cache)
def test_1_small_pad_collected(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() player = proto_game.players[0] boost = player.stats.boost self.assertEqual(boost.num_small_boosts, 1) print(analysis) run_analysis_test_on_replay(test, get_specific_replays()["1_SMALL_PAD"])
def test_offline_replay(self): local = self def test(analysis: AnalysisManager): local.assertIsNotNone(analysis.get_protobuf_data()) local.assertEqual(False, analysis.get_protobuf_data().game_metadata.is_invalid_analysis) game = analysis.get_protobuf_data() self.assertEqual(game.game_metadata.match_guid, game.game_metadata.id) run_analysis_test_on_replay(test, replay_list=get_specific_replays()["OFFLINE"])
def test_fifties_empty_if_not_intensive(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() fifties = proto_game.game_stats.fifty_fifties assert (len(fifties) == 0) # Skip test cache since this test is calculating intensive events. run_analysis_test_on_replay(test, get_raw_replays()["OCE_RLCS_7_CARS"], calculate_intensive_events=False)
def test_1_large_pad_collected(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() player = proto_game.players[0] boost = player.stats.boost assert (boost.num_large_boosts == 1) run_analysis_test_on_replay(test, get_specific_replays()["1_LARGE_PAD"], cache=replay_cache)
def test_lots_of_boost_collected(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() player = proto_game.players[0] boost = player.stats.boost assert [boost.num_small_boosts, boost.num_large_boosts] == [25, 6] run_analysis_test_on_replay(test, get_raw_replays()["6_BIG_25_SMALL"], cache=replay_cache)
def test_num_hits_detected(self, replay_cache): def test(analysis: AnalysisManager, answer): proto_game = analysis.get_protobuf_data() hits = proto_game.game_stats.hits assert (len(hits) == answer) print(analysis) run_analysis_test_on_replay(test, replay_list=get_specific_replays()["HITS"], answers=get_specific_answers()["HITS"], cache=replay_cache)
def test_pre_item_goals(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() assert proto_game.game_metadata.goals[0].extra_mode_info.pre_items assert not proto_game.game_metadata.goals[ 1].extra_mode_info.pre_items assert proto_game.game_metadata.goals[2].extra_mode_info.pre_items run_analysis_test_on_replay(test, get_raw_replays()["RUMBLE_PRE_ITEM_GOALS"], cache=replay_cache)
def test_0_boost_collected(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() player = proto_game.players[0] boost = player.stats.boost assert (boost.num_small_boosts == 0) assert (boost.num_large_boosts == 0) run_analysis_test_on_replay( test, get_specific_replays()["0_BOOST_COLLECTED"], cache=replay_cache)
def test_1_large_pad_1_small_pad_collected(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() player = proto_game.players[0] boost = player.stats.boost assert (boost.num_large_boosts == 1) assert (boost.num_small_boosts == 1) run_analysis_test_on_replay( test, get_raw_replays()["12_AND_100_BOOST_PADS_0_USED"], cache=replay_cache)
def test_no_one_for_weird_kickoffs(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() kickoffs = proto_game.game_stats.kickoffs assert (len(kickoffs) == 3) first_player = proto_game.players[0].stats kickoff_stats = first_player.kickoff_stats assert kickoff_stats.total_kickoffs == 3 run_analysis_test_on_replay(test, get_raw_replays()["WEIRD_KICKOFFS"])
def test_offline_replay(self, replay_cache): def test(analysis: AnalysisManager): assert analysis.get_protobuf_data() is not None assert not analysis.get_protobuf_data( ).game_metadata.is_invalid_analysis game = analysis.get_protobuf_data() assert game.game_metadata.match_guid, game.game_metadata.id run_analysis_test_on_replay( test, replay_list=get_specific_replays()["OFFLINE"], cache=replay_cache)
def test_0_used(self): def test(analysis: AnalysisManager, boost_value): proto_game = analysis.get_protobuf_data() player = proto_game.players[0] boost = player.stats.boost self.assertEqual(boost.boost_usage, boost_value) print(analysis) run_analysis_test_on_replay(test, get_specific_replays()["0_BOOST_USED"], answers=get_specific_answers()["0_BOOST_USED"])
def test_0_boost_collected(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() player = proto_game.players[0] boost = player.stats.boost self.assertEqual(boost.num_small_boosts, 0) self.assertEqual(boost.num_large_boosts, 0) print(analysis) run_analysis_test_on_replay(test, get_specific_replays()["0_BOOST_COLLECTED"])
def test_item_kickoff(self, replay_cache): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() self.assert_rumble_item_counts( proto_game.players[0].stats.rumble_stats, [{ 'item': BALL_FREEZE, 'used': 0, 'unused': 0 }, { 'item': BALL_GRAPPLING_HOOK, 'used': 0, 'unused': 0 }, { 'item': BALL_LASSO, 'used': 0, 'unused': 0 }, { 'item': BALL_SPRING, 'used': 2, 'unused': 0 }, { 'item': BALL_VELCRO, 'used': 0, 'unused': 0 }, { 'item': BOOST_OVERRIDE, 'used': 0, 'unused': 0 }, { 'item': CAR_SPRING, 'used': 0, 'unused': 0 }, { 'item': GRAVITY_WELL, 'used': 0, 'unused': 0 }, { 'item': STRONG_HIT, 'used': 0, 'unused': 0 }, { 'item': SWAPPER, 'used': 0, 'unused': 0 }, { 'item': TORNADO, 'used': 0, 'unused': 0 }]) run_analysis_test_on_replay(test, get_raw_replays()["RUMBLE_ITEM_KICKOFF"], cache=replay_cache)
def test_0_kickoffs(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() kickoffs = proto_game.game_stats.kickoffs assert (len(kickoffs) == 0) first_player = proto_game.players[0].stats kickoff_stats = first_player.kickoff_stats assert kickoff_stats.total_kickoffs == 0 run_analysis_test_on_replay(test, get_raw_replays()["KICKOFF_NO_TOUCH"])
def test_pre_item_goals(self): def test(analysis: AnalysisManager): proto_game = analysis.get_protobuf_data() self.assertTrue( proto_game.game_metadata.goals[0].extra_mode_info.pre_items) self.assertFalse( proto_game.game_metadata.goals[1].extra_mode_info.pre_items) self.assertTrue( proto_game.game_metadata.goals[2].extra_mode_info.pre_items) run_analysis_test_on_replay(test, get_raw_replays()["RUMBLE_PRE_ITEM_GOALS"])