chore: snapshot workflow migration progress
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
|
||||
import app.models # noqa: F401 Ensures SQLAlchemy relationships are registered.
|
||||
|
||||
from app.domains.media.models import MediaAsset, MediaAssetType
|
||||
from app.domains.pipeline.tasks.export_glb import _usd_cache_hit_refresh_reason
|
||||
from app.domains.products.models import CadFile
|
||||
|
||||
|
||||
def _build_cad_file() -> CadFile:
|
||||
return CadFile(
|
||||
id=uuid.uuid4(),
|
||||
original_name="bearing.step",
|
||||
stored_path="/tmp/bearing.step",
|
||||
file_hash=f"hash-{uuid.uuid4().hex}",
|
||||
resolved_material_assignments={
|
||||
"inner_ring": {
|
||||
"source_name": "InnerRing",
|
||||
"prim_path": "/Root/Assembly/inner_ring",
|
||||
"canonical_material": "HARTOMAT_010101_Steel-Bare",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def _build_usd_asset() -> MediaAsset:
|
||||
return MediaAsset(
|
||||
id=uuid.uuid4(),
|
||||
cad_file_id=uuid.uuid4(),
|
||||
asset_type=MediaAssetType.usd_master,
|
||||
storage_key="step_files/bearing_master.usd",
|
||||
render_config={
|
||||
"cache_key": "stephash:0.03:0.05:20.0:materialhash:scriptfingerprint",
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def test_usd_cache_hit_refresh_reason_accepts_binary_usd_without_literal_hartomat_tokens(tmp_path: Path):
|
||||
cad_file = _build_cad_file()
|
||||
usd_asset = _build_usd_asset()
|
||||
usd_path = tmp_path / "bearing_master.usd"
|
||||
usd_path.write_text("#usda 1.0\n", encoding="utf-8")
|
||||
|
||||
refresh_reason = _usd_cache_hit_refresh_reason(cad_file, usd_asset, usd_path)
|
||||
|
||||
assert refresh_reason is None
|
||||
|
||||
|
||||
def test_usd_cache_hit_refresh_reason_accepts_current_hartomat_usd(tmp_path: Path):
|
||||
cad_file = _build_cad_file()
|
||||
usd_asset = _build_usd_asset()
|
||||
usd_path = tmp_path / "bearing_master.usd"
|
||||
usd_path.write_text(
|
||||
"hartomat:canonicalMaterialName\nhartomat:partKey\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
refresh_reason = _usd_cache_hit_refresh_reason(cad_file, usd_asset, usd_path)
|
||||
|
||||
assert refresh_reason is None
|
||||
Reference in New Issue
Block a user