Beispiel #1
0
    def test_shutdown_game(self):
        """
        shutdown_game should put the list active_players on game_info['kills']
        should also clear the list active_players
        should add one to the count of current_game
        should call print_game()
        """
        intersection = [{'Fulano': 56}, {'Deltrano': 1}, {'Jack': 0}]
        active_players_mock = {
            '2': ['Fulano', 56],
            '6': ['Deltrano', 1],
            '12': ['Jack', 0]
        }
        kills_mock = [{'Player1': 3}, {'Player2': 987}]

        parser = Parser()

        with mock.patch('core.Parser.print_game') as mockFunc:
            parser.active_players = active_players_mock
            parser.game_info['kills'] = kills_mock
            parser.current_game = 11
            parser.shutdown_game()

            assert parser.current_game == 12
            mockFunc.assert_called_once_with()
            self.assertDictEqual(parser.game_info['kills'][2], intersection[0])
            self.assertDictEqual(parser.game_info['kills'][3], intersection[1])
            self.assertDictEqual(parser.game_info['kills'][4], intersection[2])
Beispiel #2
0
    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