diff --git a/backend/tests/__pycache__/conftest.cpython-314-pytest-9.0.3.pyc b/backend/tests/__pycache__/conftest.cpython-314-pytest-9.0.3.pyc new file mode 100644 index 0000000..cc1bf02 Binary files /dev/null and b/backend/tests/__pycache__/conftest.cpython-314-pytest-9.0.3.pyc differ diff --git a/backend/tests/__pycache__/test_jobs.cpython-314-pytest-9.0.3.pyc b/backend/tests/__pycache__/test_jobs.cpython-314-pytest-9.0.3.pyc new file mode 100644 index 0000000..d87740a Binary files /dev/null and b/backend/tests/__pycache__/test_jobs.cpython-314-pytest-9.0.3.pyc differ diff --git a/backend/tests/__pycache__/test_sources.cpython-314-pytest-9.0.3.pyc b/backend/tests/__pycache__/test_sources.cpython-314-pytest-9.0.3.pyc new file mode 100644 index 0000000..c7bd3aa Binary files /dev/null and b/backend/tests/__pycache__/test_sources.cpython-314-pytest-9.0.3.pyc differ diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py index 8551487..f47b1dc 100644 --- a/backend/tests/conftest.py +++ b/backend/tests/conftest.py @@ -3,7 +3,7 @@ import pytest_asyncio from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker from app.database import Base, get_db from app.main import app -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:" @@ -28,6 +28,6 @@ async def client(db): yield db app.dependency_overrides[get_db] = override_get_db - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: yield ac app.dependency_overrides.clear() diff --git a/backend/tests/test_jobs.py b/backend/tests/test_jobs.py index 05bfa21..69ac483 100644 --- a/backend/tests/test_jobs.py +++ b/backend/tests/test_jobs.py @@ -1,10 +1,10 @@ import pytest -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from app.main import app @pytest.mark.asyncio async def test_create_job(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: # Create a source first (job requires source_id) source_resp = await ac.post("/api/sources/", json={ "name": "Test Source", @@ -31,7 +31,7 @@ async def test_create_job(): @pytest.mark.asyncio async def test_list_jobs(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: # Create source and job source_resp = await ac.post("/api/sources/", json={ "name": "Test Source", @@ -56,7 +56,7 @@ async def test_list_jobs(): @pytest.mark.asyncio async def test_get_job(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: source_resp = await ac.post("/api/sources/", json={ "name": "Test Source", "type": "local", @@ -80,7 +80,7 @@ async def test_get_job(): @pytest.mark.asyncio async def test_delete_job(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: source_resp = await ac.post("/api/sources/", json={ "name": "Test Source", "type": "local", @@ -102,13 +102,13 @@ async def test_delete_job(): assert response.status_code == 200 # Verify deletion - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: get_resp = await ac.get(f"/api/jobs/{job_id}") assert get_resp.status_code == 404 @pytest.mark.asyncio async def test_run_job(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: # Create source source_resp = await ac.post("/api/sources/", json={ "name": "Test Source", @@ -134,13 +134,13 @@ async def test_run_job(): @pytest.mark.asyncio async def test_run_job_not_found(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: response = await ac.post("/api/jobs/999/run") assert response.status_code == 404 @pytest.mark.asyncio async def test_update_job(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: # Create source source_resp = await ac.post("/api/sources/", json={ "name": "Test Source", @@ -169,7 +169,7 @@ async def test_update_job(): @pytest.mark.asyncio async def test_create_schedule(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: # Create source source_resp = await ac.post("/api/sources/", json={ "name": "Test Source", @@ -202,18 +202,18 @@ async def test_create_schedule(): @pytest.mark.asyncio async def test_get_job_not_found(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: response = await ac.get("/api/jobs/99999") assert response.status_code == 404 @pytest.mark.asyncio async def test_update_job_not_found(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: response = await ac.put("/api/jobs/99999", json={"name": "Test"}) assert response.status_code == 404 @pytest.mark.asyncio async def test_delete_job_not_found(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: response = await ac.delete("/api/jobs/99999") assert response.status_code == 404 diff --git a/backend/tests/test_sources.py b/backend/tests/test_sources.py index 7c9f511..d8f08ee 100644 --- a/backend/tests/test_sources.py +++ b/backend/tests/test_sources.py @@ -1,10 +1,10 @@ import pytest -from httpx import AsyncClient +from httpx import AsyncClient, ASGITransport from app.main import app @pytest.mark.asyncio async def test_create_source(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: response = await ac.post("/api/sources/", json={ "name": "Test Source", "type": "local", @@ -18,7 +18,7 @@ async def test_create_source(): @pytest.mark.asyncio async def test_list_sources(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: # Create source first await ac.post("/api/sources/", json={ "name": "Test Source", @@ -33,7 +33,7 @@ async def test_list_sources(): @pytest.mark.asyncio async def test_get_source(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: create_resp = await ac.post("/api/sources/", json={ "name": "Test Source", "type": "local", @@ -47,7 +47,7 @@ async def test_get_source(): @pytest.mark.asyncio async def test_delete_source(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: create_resp = await ac.post("/api/sources/", json={ "name": "Delete Me", "type": "local", @@ -59,13 +59,13 @@ async def test_delete_source(): assert response.status_code == 200 # Verify deletion - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(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: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: create_resp = await ac.post("/api/sources/", json={ "name": "Original Name", "type": "local", @@ -82,18 +82,18 @@ async def test_update_source(): @pytest.mark.asyncio async def test_get_source_not_found(): - async with AsyncClient(app=app, base_url="http://test") as ac: + async with AsyncClient(transport=ASGITransport(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: + async with AsyncClient(transport=ASGITransport(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: + async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as ac: response = await ac.delete("/api/sources/99999") assert response.status_code == 404