def test_get_neighbours_edge():
    """Check that the correct neighbours are returned for an edge position.
    """
    board = Board()

    expected_neighbours = [(3, 6), (3, 5), (4, 4), (5, 4)]
    actual_neighbours = board.get_neighbours(position=(4, 5))

    assert len(actual_neighbours) == len(expected_neighbours)
    assert set(actual_neighbours) == set(expected_neighbours)
def test_get_neighbours_center():
    """Check that the correct neighbours are returned for the central position.
    """
    board = Board()

    expected_neighbours = [(3, 2), (4, 2), (4, 3), (3, 4), (2, 4), (2, 3)]
    actual_neighbours = board.get_neighbours(position=(3, 3))

    assert len(actual_neighbours) == len(expected_neighbours)
    assert set(actual_neighbours) == set(expected_neighbours)
def test_is_fenced_edge():
    """Check that the function correctly classifies a fenced bloom at the edge
    of the board.
    """
    board = Board()

    # Add a bloom
    bloom = [(6, 3), (5, 4)]
    for position in bloom:
        board.place_stone(position, colour=1)

    # Fence the bloom
    for position in bloom:
        neighbours = board.get_neighbours(position)
        for neighbour in neighbours:
            if board.is_empty_space(neighbour):
                board.place_stone(neighbour, colour=2)

    assert board.is_fenced(bloom)
def test_is_fenced_false():
    """Check that the function correctly classifies a non-fenced bloom.
    """
    board = Board()

    # Add a bloom
    bloom = [(3, 2), (3, 3), (3, 4), (4, 3)]
    for position in bloom:
        board.place_stone(position, colour=1)

    # Fence the bloom
    for position in bloom:
        neighbours = board.get_neighbours(position)
        for neighbour in neighbours:
            if board.is_empty_space(neighbour):
                board.place_stone(neighbour, colour=2)

    # Remove one of the stones fencing in the bloom
    board.remove_stone(position=(4, 4))

    assert not board.is_fenced(bloom)