def test_score_kill(self): """ score_kill should give points to the player that killed should take out one point if the player died from <world> should increase the count of total kills should increase the kill count of that death cause """ death_causes = [{ 'death_cause': 0 }, { 'death_cause': 0 }, { 'death_cause': 0 }] active_players_mock = { '2': ['Fulano', 5], '6': ['Deltrano', 1], '12': ['Jack', 0] } parser = Parser() parser.death_causes = death_causes parser.active_players = active_players_mock parser.game_info['total_kills'] = 6 # World kill parser.score_kill('1022 2 0: something something') assert parser.game_info['total_kills'] == 7 assert parser.active_players['2'][1] == 4 assert parser.death_causes[0]['death_cause'] == 1 # Player kill parser.score_kill('6 12 2: something something') assert parser.game_info['total_kills'] == 8 assert parser.active_players['6'][1] == 2 assert parser.death_causes[2]['death_cause'] == 1
def test_print_game(self): """ print_game should get the top player of the match should get the deaths by cause should dump all the game info into game_json """ game_info_mock = { 'total_kills': 34, 'players': ['Fulano', 'Player1', 'Player2'], 'kills': [{ 'Player1': 3 }, { 'Player2': 12 }, { 'Fulano': 6 }], 'kills_by_means': {} } death_causes_mock = [{ 'death_cause0': 6 }, { 'death_cause1': 0 }, { 'death_cause2': 28 }] death_causes_base_mock = [{ 'death_cause0': 0 }, { 'death_cause1': 0 }, { 'death_cause2': 0 }] cheat_sheet = { 'total_kills': 34, 'players': ['Fulano', 'Player1', 'Player2'], 'kills': [{ 'Player1': 3 }, { 'Player2': 12 }, { 'Fulano': 6 }], 'kills_by_means': { 'death_cause0': 6, 'death_cause2': 28 }, 'top_player': 'Player2' } parser = Parser() parser.game_info = game_info_mock parser.death_causes = death_causes_mock parser.current_game = 15 parser.print_game() assert parser.death_causes == death_causes_base_mock assert parser.game_json['game-15'] == cheat_sheet