Beispiel #1
0
    def test_init_game(self):
        """
        init_game should rest game_info to be equal base_dict
        """
        game_info_mock = {'item': 'some item', 'action': 'a random action'}
        base_dict_mock = {
            'word': 'the corresponding word',
            'something': [],
            'anotherThing': {}
        }

        parser = Parser()

        parser.game_info = game_info_mock
        parser.base_dict = base_dict_mock
        parser.init_game()
        assert parser.game_info == base_dict_mock
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