Пример #1
0
def test_ball_dict_fills_with_balls():
    fake_game_interface = GameInterface(None)
    fake_game_interface.ball_dict = defaultdict(dict)

    fake_game_interface._fill_ball_dict()

    first_ball = fake_game_interface.ball_dict[0][0]
    expected_type = "<class 'match_three.Fields'>"
    actual_type = str(type(first_ball))
    assert expected_type == actual_type
Пример #2
0
def test_ball_dict_fills_with_expected_number_of_balls():
    fake_game_interface = GameInterface(None)
    fake_game_interface.ball_dict = defaultdict(dict)

    fake_game_interface._fill_ball_dict()

    expected_no_balls_in_dict = fake_game_interface.no_lines * \
    fake_game_interface.no_columns
    actual_no_balls_in_dict = 0
    for layer in fake_game_interface.ball_dict:
        actual_no_balls_in_dict += len(fake_game_interface.ball_dict[layer])
    assert expected_no_balls_in_dict == actual_no_balls_in_dict
Пример #3
0
def fake_interface_preparation(scope="function"):
    fake_game_interface = GameInterface(None)
    fake_game_interface.part_of_three = np.zeros(
        [fake_game_interface.no_lines, fake_game_interface.no_columns])
    colors = {0: "black", 1: "red", 2: "green"}

    for row_index in range(fake_game_interface.no_lines):
        for column_index in range(fake_game_interface.no_lines):
            if row_index % 2 == 0:
                fake_game_interface.ball_dict[row_index][column_index].color =\
                colors[column_index%3]
            else:
                fake_game_interface.ball_dict[row_index][column_index].color =\
                colors[(column_index+1)%3]
    yield fake_game_interface
    del fake_game_interface
Пример #4
0
def test_update_round_increments_round_counter():
    fake_game_interface = GameInterface(None)
    fake_game_interface.game_stat.round = 1
    assert fake_game_interface.game_stat.get_round() == 1
    fake_game_interface._update_round()
    assert fake_game_interface.game_stat.get_round() == 2