Esempio n. 1
0
def test_after_series_of_creates_and_removes_no_corners_empty():
    """ Tests create_piece. Adds three pieces, removes two, adds three,
    and checks that all pieces are on a different corner """
    board = Board(create_random_maze())
    piece1 = board.create_piece()
    piece2 = board.create_piece()
    board.create_piece()
    board.remove_piece(piece1)
    board.remove_piece(piece2)
    board.create_piece()
    board.create_piece()
    board.create_piece()
    assert len(board.pieces) == 4
    piece_cards = {piece.maze_card for piece in board.pieces}
    assert len(piece_cards) == 4
Esempio n. 2
0
def test_create_piece_assigns_pieces_consecutive_unique_indices():
    """ Tests create_piece. Adds four pieces, removes first two, adds one, removes third, adds two,
    and checks that all pieces have consecutive unique index """
    board = Board(create_random_maze())
    pieces = [
        board.create_piece(),
        board.create_piece(),
        board.create_piece(),
        board.create_piece()
    ]
    board.remove_piece(pieces[0])
    board.remove_piece(pieces[1])
    pieces[0] = board.create_piece()
    board.remove_piece(pieces[3])
    pieces[1] = board.create_piece()
    pieces[3] = board.create_piece()
    assert set([0, 1, 2,
                3]) == set(map(lambda piece: piece.piece_index, pieces))
Esempio n. 3
0
def test_remove_piece_after_create_piece():
    """ Tests remove_piece """
    board = Board(create_random_maze())
    piece = board.create_piece()
    board.remove_piece(piece)
    assert not board.pieces