bim-twin-viewer/backend/tests/test_upload.py
warnason 97f5dfadae Add test suite and polish project documentation
- 7 pytest tests covering health, upload validation, API responses, schemas
- Updated README with architecture diagram, feature list, design decisions
- Live demo link and complete API reference
2026-04-27 10:53:53 +02:00

34 lines
1.1 KiB
Python

"""Test the IFC upload endpoint."""
import pytest
from httpx import ASGITransport, AsyncClient
from app.main import app
@pytest.mark.asyncio
async def test_upload_rejects_non_ifc():
"""Upload endpoint rejects files without .ifc extension."""
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as client:
response = await client.post(
"/api/upload",
files={"file": ("model.obj", b"dummy content", "application/octet-stream")},
)
assert response.status_code == 400
assert "Only .ifc files" in response.json()["detail"]
@pytest.mark.asyncio
async def test_upload_rejects_empty_filename():
"""Upload endpoint rejects files with wrong extension."""
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as client:
response = await client.post(
"/api/upload",
files={"file": ("readme.txt", b"not an ifc file", "text/plain")},
)
assert response.status_code == 400