Files
HartOMat/backend/tests/integration/test_cad_model_endpoint.py
T

49 lines
1.2 KiB
Python

from __future__ import annotations
import uuid
import pytest
@pytest.mark.integration
@pytest.mark.asyncio
async def test_cad_model_endpoint_falls_back_to_gltf_geometry_asset(
client,
db,
auth_headers,
tmp_path,
):
from app.domains.media.models import MediaAsset, MediaAssetType
from app.domains.products.models import CadFile, ProcessingStatus
glb_path = tmp_path / "example.glb"
glb_path.write_bytes(b"glTF")
cad = CadFile(
id=uuid.uuid4(),
original_name="example.step",
stored_path=str(tmp_path / "example.step"),
file_hash="cad-model-endpoint-fallback",
file_size=123,
processing_status=ProcessingStatus.completed,
gltf_path=None,
)
db.add(cad)
await db.flush()
asset = MediaAsset(
id=uuid.uuid4(),
cad_file_id=cad.id,
asset_type=MediaAssetType.gltf_geometry,
storage_key=str(glb_path),
mime_type="model/gltf-binary",
)
db.add(asset)
await db.commit()
response = await client.get(f"/api/cad/{cad.id}/model", headers=auth_headers)
assert response.status_code == 200
assert response.headers["content-type"] == "model/gltf-binary"
assert response.content == b"glTF"