예제 #1
0
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
예제 #2
0
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
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
def test_load_players_1():
    player_test = player.Player('Maciek', 20)
    output = player_test.load_players()

    assert isinstance(output, list)
예제 #6
0
def test_set_player_score_2():
    player_test = player.Player('Maciek', 20)

    player_test.set_player_score(8)

    assert player_test.score == 8
예제 #7
0
def test_add_to_score_1():
    player_test = player.Player('Maciek', 20)

    player_test.add_to_score(5)

    assert player_test.score == 25
예제 #8
0
def test_set_player_name_2():
    player_test = player.Player('Maciek', 20)

    player_test.set_player_name('Wojtek')

    assert player_test.name == 'Wojtek'
예제 #9
0
def test_set_player_name_1():
    player_test = player.Player('Maciek', 20)

    player_test.set_player_name('Karol')

    assert player_test.name == 'Karol'
예제 #10
0
def test_get_player_name_1():
    player_test = player.Player('Adam', 0)

    output = player_test.get_player_name()

    assert output == 'Adam'
예제 #11
0
def test_get_player_score_2():
    player_test = player.Player('Maciek', 20)

    output = player_test.get_player_score()

    assert output == 20
예제 #12
0
def test_get_player_name_2():
    player_test = player.Player('Maciek', 0)

    output = player_test.get_player_name()

    assert output == 'Maciek'