From 810aae1b6ea43090c820c57f0c39f10817312f56 Mon Sep 17 00:00:00 2001 From: Alex Blank Date: Mon, 11 May 2026 21:01:41 +0200 Subject: [PATCH] test: add update and 404 tests for sources API --- backend/tests/test_sources.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/backend/tests/test_sources.py b/backend/tests/test_sources.py index 8709b94..7c9f511 100644 --- a/backend/tests/test_sources.py +++ b/backend/tests/test_sources.py @@ -62,3 +62,38 @@ async def test_delete_source(): async with AsyncClient(app=app, base_url="http://test") as ac: get_resp = await ac.get(f"/api/sources/{source_id}") 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