def test_parse_json_str_1(): j_string = '{"id": "18ddb594-7246-4c05-a751-65a8271d71ed", "name": "Maciek", "score": 20}' player_test = player.Player('Maciek', 20) player_test.parse_json_str(j_string) player_2 = player.Player() player_2.name = "Maciek" player_2.id = "18ddb594-7246-4c05-a751-65a8271d71ed" player_2.score = 20 assert player_2.id == player_test.id and player_2.name == player_test.name and player_2.score == player_test.score
def test_choose_player(): player_1 = player.Player() player_1.id = 5 players_list = [player_1] player_test = player.Player.choose_player(5, players_list) assert player_1 == player_test
def load_game(): players = player.Player.load_players() player_1 = player.Player() players_list = [] for item in players: player_1.parse_json_str(item) players_list.append(player_1) print(player_1) ans = input("Enter id: ") return player_1.choose_player(ans, players_list)
from quiz_ten_questions import questions from quiz_ten_questions import utils from quiz_ten_questions import player from quiz_ten_questions import gameplay utils.welcome_message() # TODO: Add admin mode here ans = input('''1 - start new game 2 - load game ''') if ans == '1': name = input("Enter your name") player = player.Player(name) player.save_player() elif ans == '2': player_1 = utils.load_game() player = player_1 print(player) else: print("Please enter proper value (1 or 2)") questions_list = utils.choose_questions() question = questions.Questions() for item in questions_list: question.convert_from_dict_to_instance(item) question.display() ans = gameplay.ask_for_answer() is_good = question.check_answer(ans)
def test_load_players_1(): player_test = player.Player('Maciek', 20) output = player_test.load_players() assert isinstance(output, list)
def test_set_player_score_2(): player_test = player.Player('Maciek', 20) player_test.set_player_score(8) assert player_test.score == 8
def test_add_to_score_1(): player_test = player.Player('Maciek', 20) player_test.add_to_score(5) assert player_test.score == 25
def test_set_player_name_2(): player_test = player.Player('Maciek', 20) player_test.set_player_name('Wojtek') assert player_test.name == 'Wojtek'
def test_set_player_name_1(): player_test = player.Player('Maciek', 20) player_test.set_player_name('Karol') assert player_test.name == 'Karol'
def test_get_player_name_1(): player_test = player.Player('Adam', 0) output = player_test.get_player_name() assert output == 'Adam'
def test_get_player_score_2(): player_test = player.Player('Maciek', 20) output = player_test.get_player_score() assert output == 20
def test_get_player_name_2(): player_test = player.Player('Maciek', 0) output = player_test.get_player_name() assert output == 'Maciek'