chore: snapshot workflow migration progress

This commit is contained in:
2026-04-12 11:49:04 +02:00
parent 0cd02513d5
commit 3e810c74a3
163 changed files with 31774 additions and 2753 deletions
@@ -0,0 +1,48 @@
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"
@@ -0,0 +1,30 @@
from __future__ import annotations
import uuid
import pytest
@pytest.mark.asyncio
async def test_batch_delete_assets_awaits_global_admin_guard(client, auth_headers, monkeypatch):
guard_calls: list[str] = []
deleted_asset_ids: list[str] = []
async def _guard(user):
guard_calls.append(str(user.id))
return user
async def _delete_media_asset(_db, asset_id):
deleted_asset_ids.append(str(asset_id))
return True
monkeypatch.setattr("app.utils.auth.require_global_admin", _guard)
monkeypatch.setattr("app.domains.media.service.delete_media_asset", _delete_media_asset)
asset_ids = [str(uuid.uuid4()), str(uuid.uuid4())]
response = await client.post("/api/media/batch-delete", json=asset_ids, headers=auth_headers)
assert response.status_code == 200, response.text
assert len(guard_calls) == 1
assert deleted_asset_ids == asset_ids
assert response.json() == {"deleted": 2, "requested": 2}