import io import pytest from httpx import AsyncClient @pytest.mark.asyncio async def test_upload_recording(auth_client: AsyncClient): file_content = b"\x00" * 1024 resp = await auth_client.post( "/api/recordings/upload", files={"file": ("test.mp4", io.BytesIO(file_content), "video/mp4")}, data={"title": "Test Meeting"}, ) assert resp.status_code == 201 data = resp.json() assert data["title"] == "Test Meeting" assert data["format"] == "mp4" assert data["source"] == "web" assert data["status"] == "uploaded" @pytest.mark.asyncio async def test_upload_unsupported_format(auth_client: AsyncClient): resp = await auth_client.post( "/api/recordings/upload", files={"file": ("test.exe", io.BytesIO(b"\x00"), "application/octet-stream")}, ) assert resp.status_code == 400 @pytest.mark.asyncio async def test_list_recordings(auth_client: AsyncClient): await auth_client.post( "/api/recordings/upload", files={"file": ("list_test.mp3", io.BytesIO(b"\x00" * 512), "audio/mp3")}, ) resp = await auth_client.get("/api/recordings") assert resp.status_code == 200 data = resp.json() assert data["total"] >= 1 assert len(data["items"]) >= 1 @pytest.mark.asyncio async def test_get_recording_by_id(auth_client: AsyncClient): upload_resp = await auth_client.post( "/api/recordings/upload", files={"file": ("get_test.wav", io.BytesIO(b"\x00" * 256), "audio/wav")}, ) rec_id = upload_resp.json()["id"] resp = await auth_client.get(f"/api/recordings/{rec_id}") assert resp.status_code == 200 assert resp.json()["id"] == rec_id @pytest.mark.asyncio async def test_delete_recording(auth_client: AsyncClient): upload_resp = await auth_client.post( "/api/recordings/upload", files={"file": ("del_test.ogg", io.BytesIO(b"\x00" * 128), "audio/ogg")}, ) rec_id = upload_resp.json()["id"] resp = await auth_client.delete(f"/api/recordings/{rec_id}") assert resp.status_code == 204