Exemplo n.º 1
0
def test_board_set_tile_sets_only_tile():
    board = Board(empty_tiles(4))
    board = set_tile(board, 1, 2, 3)
    assert board.tiles == [
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 3, 0, 0],
        [0, 0, 0, 0],
    ]
Exemplo n.º 2
0
def test_get_tile_should_error_on_negative_col():
    board = Board(empty_tiles(4))

    with raises(AttributeError):
        get_tile(board, -1, 1)
Exemplo n.º 3
0
def test_get_tile():
    board = Board(empty_tiles(4))
    board = set_tile(board, 1, 2, 3)
    assert get_tile(board, 1, 2) == 3
Exemplo n.º 4
0
def test_board_size():
    board = Board(empty_tiles(4))

    assert board.size == 4
Exemplo n.º 5
0
def test_set_tile_should_not_error_on_max_value():
    board = Board(empty_tiles(4))
    set_tile(board, 0, 0, 4)
Exemplo n.º 6
0
def test_set_tile_should_error_on_value_too_high():
    board = Board(empty_tiles(4))

    with raises(AttributeError):
        set_tile(board, 0, 0, 5)
Exemplo n.º 7
0
def test_empty_tiles_should_fill_all_zero():
    assert empty_tiles(3) == [
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
    ]
Exemplo n.º 8
0
def test_set_tile_should_error_on_negative_value():
    board = Board(empty_tiles(4))

    with raises(AttributeError):
        set_tile(board, 0, 0, -1)
Exemplo n.º 9
0
def test_solve_backtrack_empty_board():
    board = Board(empty_tiles(9))
    _solution, solved = solve_backtrack(board)

    assert solved
Exemplo n.º 10
0
def test_board_should_start_empty():
    board = Board(empty_tiles(9))
    assert board.tiles == [[0] * 9] * 9
Exemplo n.º 11
0
def test_board_error_on_size_not_square_number():
    with raises(AttributeError):
        Board(empty_tiles(12))
Exemplo n.º 12
0
def test_board_no_error_when_size_is_square_number():
    Board(empty_tiles(81))
Exemplo n.º 13
0
def test_get_tile_should_error_on_col_too_high():
    board = Board(empty_tiles(4))

    with raises(AttributeError):
        get_tile(board, 4, 1)
Exemplo n.º 14
0
def test_post_to_solve_empty_board_should_have_solved_in_response(client: TestClient):
    response = client.post('/solve', json={'board': empty_tiles(9)})
    data = response.json()

    assert 'solved' in data
    assert data['solved'] == True