Пример #1
0
def test_delete_element():
    Grids.reset()
    grid_id = Grids.create_grid()
    element = MagicMock()
    Grids.insert_element(grid_id, 10, 10, element)
    assert Grids.grids[grid_id][10][10] == element

    Grids.delete_element(grid_id, 10, 10)
    assert Grids.grids[grid_id][10][10] is None
Пример #2
0
def test_delete_element_invalid_position():
    Grids.reset()
    grid_id = Grids.create_grid()
    with pytest.raises(HTTPException) as e:
        Grids.delete_element(grid_id, -1, 10)
    assert e.value.status_code == 400
    assert e.value.detail == "position is invalid"

    with pytest.raises(HTTPException) as e:
        Grids.delete_element(grid_id, 50, 10)
    assert e.value.status_code == 400
    assert e.value.detail == "position is invalid"

    with pytest.raises(HTTPException) as e:
        Grids.delete_element(grid_id, 10, -1)
    assert e.value.status_code == 400
    assert e.value.detail == "position is invalid"

    with pytest.raises(HTTPException) as e:
        Grids.delete_element(grid_id, 10, 50)
    assert e.value.status_code == 400
    assert e.value.detail == "position is invalid"
Пример #3
0
def test_delete_element_grid_not_found():
    Grids.reset()
    with pytest.raises(HTTPException) as e:
        Grids.delete_element(0, 1, 2)
    assert e.value.status_code == 404
    assert e.value.detail == "grid not found"