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])