feat: Add endpoint to retrieve currently processing extractions and corresponding tests
Some checks failed
Backend CI / lint (push) Failing after 4m54s
Backend CI / test (push) Failing after 4m39s

This commit is contained in:
JSC
2025-08-24 13:44:01 +02:00
parent 16eb789539
commit d81a54207c
2 changed files with 89 additions and 0 deletions

View File

@@ -184,3 +184,48 @@ class TestExtractionEndpoints:
data = response.json()
assert "extractions" in data
assert isinstance(data["extractions"], list)
@pytest.mark.asyncio
async def test_get_processing_extractions(
self,
test_client: AsyncClient,
auth_cookies: dict[str, str],
test_session: AsyncSession,
authenticated_user: User,
) -> None:
"""Test getting currently processing extractions."""
# Create a processing extraction
processing_extraction = Extraction(
url="https://www.youtube.com/watch?v=processing",
user_id=authenticated_user.id,
service="youtube",
service_id="processing123",
title="Processing Video",
status="processing",
)
test_session.add(processing_extraction)
await test_session.commit()
await test_session.refresh(processing_extraction)
# Set cookies on client instance
test_client.cookies.update(auth_cookies)
response = await test_client.get("/api/v1/extractions/processing/current")
# Should succeed and return the processing extraction
assert response.status_code == 200
data = response.json()
assert isinstance(data, list)
assert len(data) >= 1
# Find our processing extraction in the results
processing_found = False
for extraction in data:
if extraction["id"] == processing_extraction.id:
processing_found = True
assert extraction["status"] == "processing"
assert extraction["title"] == "Processing Video"
assert extraction["url"] == "https://www.youtube.com/watch?v=processing"
break
assert processing_found, "Processing extraction not found in results"