test: add update and 404 tests for sources API
This commit is contained in:
@@ -62,3 +62,38 @@ async def test_delete_source():
|
|||||||
async with AsyncClient(app=app, base_url="http://test") as ac:
|
async with AsyncClient(app=app, base_url="http://test") as ac:
|
||||||
get_resp = await ac.get(f"/api/sources/{source_id}")
|
get_resp = await ac.get(f"/api/sources/{source_id}")
|
||||||
assert get_resp.status_code == 404
|
assert get_resp.status_code == 404
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_update_source():
|
||||||
|
async with AsyncClient(app=app, base_url="http://test") as ac:
|
||||||
|
create_resp = await ac.post("/api/sources/", json={
|
||||||
|
"name": "Original Name",
|
||||||
|
"type": "local",
|
||||||
|
"config": {"path": "/tmp/test"}
|
||||||
|
})
|
||||||
|
source_id = create_resp.json()["id"]
|
||||||
|
|
||||||
|
response = await ac.put(f"/api/sources/{source_id}", json={
|
||||||
|
"name": "Updated Name"
|
||||||
|
})
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.json()["name"] == "Updated Name"
|
||||||
|
assert response.json()["type"] == "local" # Unchanged
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_get_source_not_found():
|
||||||
|
async with AsyncClient(app=app, base_url="http://test") as ac:
|
||||||
|
response = await ac.get("/api/sources/99999")
|
||||||
|
assert response.status_code == 404
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_update_source_not_found():
|
||||||
|
async with AsyncClient(app=app, base_url="http://test") as ac:
|
||||||
|
response = await ac.put("/api/sources/99999", json={"name": "Test"})
|
||||||
|
assert response.status_code == 404
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_delete_source_not_found():
|
||||||
|
async with AsyncClient(app=app, base_url="http://test") as ac:
|
||||||
|
response = await ac.delete("/api/sources/99999")
|
||||||
|
assert response.status_code == 404
|
||||||
|
|||||||
Reference in New Issue
Block a user