chore: snapshot workflow migration progress
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _load_blender_materials_module():
|
||||
candidates = [
|
||||
Path(__file__).resolve().parents[1] / "render-worker" / "scripts" / "_blender_materials.py",
|
||||
Path("/compose/render-worker/scripts/_blender_materials.py"),
|
||||
]
|
||||
module_path = next((path for path in candidates if path.exists()), None)
|
||||
assert module_path is not None
|
||||
spec = importlib.util.spec_from_file_location("test_blender_materials", module_path)
|
||||
assert spec is not None
|
||||
assert spec.loader is not None
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
def test_lookup_material_name_matches_usd_part_keys_without_serial_suffixes():
|
||||
module = _load_blender_materials_module()
|
||||
mat_map = module.build_mat_map_lower(
|
||||
{
|
||||
"RWDR_B_F-802044_TR4_H122B-69186": "Steel--Stahl",
|
||||
"RWDR_B_F-802044_TR4_H122B-72661": "Steel--Stahl",
|
||||
"O_RING_RG_F-802044_TR4_H-120220": "Eslastomer_black--Elastomer_schwarz",
|
||||
"O_RING_RG_F-802044_TR4_H-120399": "Eslastomer_black--Elastomer_schwarz",
|
||||
"F-802044-3001_IR_TR2-H_A1-25921_AF0": "Steel--Stahl",
|
||||
"F-802044-3001_IR_TR2-H_A1-53810_AF0": "Steel--Stahl",
|
||||
}
|
||||
)
|
||||
|
||||
assert (
|
||||
module.lookup_material_name(
|
||||
"RWDR_B_F-802044_TR4_H122BK",
|
||||
mat_map,
|
||||
"rwdr_b_f_802044_tr4_h122bk",
|
||||
)
|
||||
== "Steel--Stahl"
|
||||
)
|
||||
assert (
|
||||
module.lookup_material_name(
|
||||
"O_RING_RG_F-802044_TR4_H122BK_1",
|
||||
mat_map,
|
||||
"o_ring_rg_f_802044_tr4_h122bk_1",
|
||||
)
|
||||
== "Eslastomer_black--Elastomer_schwarz"
|
||||
)
|
||||
assert (
|
||||
module.lookup_material_name(
|
||||
"F-802044-3001_IR_TR2-H_A1_04",
|
||||
mat_map,
|
||||
"f_802044_3001_ir_tr2_h_a1_04",
|
||||
)
|
||||
== "Steel--Stahl"
|
||||
)
|
||||
|
||||
|
||||
def test_lookup_material_name_keeps_ambiguous_fuzzy_matches_unresolved():
|
||||
module = _load_blender_materials_module()
|
||||
mat_map = module.build_mat_map_lower(
|
||||
{
|
||||
"PART_ALPHA-11111": "Steel--Stahl",
|
||||
"PART_ALPHA-22222": "Bronze--Bronze",
|
||||
}
|
||||
)
|
||||
|
||||
assert module.lookup_material_name("PART_ALPHA", mat_map) is None
|
||||
|
||||
|
||||
def test_iter_object_name_variants_strips_blender_duplicate_suffix():
|
||||
module = _load_blender_materials_module()
|
||||
|
||||
assert list(module._iter_object_name_variants("BearingHousing.001")) == [
|
||||
"BearingHousing.001",
|
||||
"BearingHousing",
|
||||
]
|
||||
|
||||
assert list(module._iter_object_name_variants("BearingHousing")) == [
|
||||
"BearingHousing",
|
||||
]
|
||||
Reference in New Issue
Block a user