Ejemplo n.º 1
0
def test_remove_stone_invalid():
    """Check that the function raises an error when there is no stone to be
    removed.
    """
    board = Board()

    with pytest.raises(AssertionError):
        board.remove_stone(position=(3, 3))
Ejemplo n.º 2
0
def test_remove_stone_valid():
    """Check that the function removes a stone from the board (when there is
    one present.
    """
    board = Board()
    board.place_stone(position=(3, 3), colour=1)
    board.remove_stone(position=(3, 3))

    assert board.is_empty_space(position=(3, 3))
Ejemplo n.º 3
0
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)