75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
"""Unit tests for Phase 2: 3D Asset Validation and Manifest Integrity."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def manifest_path(project_root: Path) -> Path:
|
|
return project_root / "config" / "asset_manifest.json"
|
|
|
|
|
|
def test_asset_manifest_structure_and_completeness(manifest_path: Path):
|
|
"""Verify that asset_manifest.json exists, is valid JSON, and contains required assets."""
|
|
assert manifest_path.exists(), f"Asset manifest missing at {manifest_path}"
|
|
|
|
with open(manifest_path, "r", encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
|
|
assert data["version"] == "1.0.0"
|
|
assert data["meters_per_unit"] == 1.0
|
|
assert data["up_axis"] == "Z"
|
|
assert "assets" in data
|
|
|
|
assets = data["assets"]
|
|
required_keys = [
|
|
"pallet_rack_heavy",
|
|
"shelving_unit_light",
|
|
"euro_pallet",
|
|
"pallet_with_cartons",
|
|
"amr_light",
|
|
"amr_heavy",
|
|
"dock_inbound",
|
|
"picking_station",
|
|
"charging_station",
|
|
"safety_barrier",
|
|
"building_shell",
|
|
]
|
|
|
|
for key in required_keys:
|
|
assert key in assets, f"Required asset '{key}' missing from manifest"
|
|
entry = assets[key]
|
|
assert "path" in entry
|
|
assert "dimensions" in entry
|
|
assert len(entry["dimensions"]) == 3
|
|
assert "role" in entry
|
|
|
|
|
|
def test_manifest_assets_exist_on_disk(project_root: Path, manifest_path: Path):
|
|
"""Verify that every asset referenced in the manifest physically exists and is non-empty."""
|
|
with open(manifest_path, "r", encoding="utf-8") as f:
|
|
data = json.load(f)
|
|
|
|
for asset_id, entry in data["assets"].items():
|
|
rel_path = entry["path"]
|
|
file_path = project_root / rel_path
|
|
assert file_path.exists(), f"Asset file for '{asset_id}' does not exist at {file_path}"
|
|
assert file_path.stat().st_size > 100, f"Asset file for '{asset_id}' is empty or too small"
|
|
|
|
|
|
def test_rack_and_robot_usda_syntax(project_root: Path):
|
|
"""Verify OpenUSD syntax conventions for rack and robot models (Phase 2 validation)."""
|
|
rack_file = project_root / "assets" / "racks" / "pallet_rack_heavy.usda"
|
|
robot_file = project_root / "assets" / "robots" / "amr_light.usda"
|
|
|
|
for fpath in (rack_file, robot_file):
|
|
text = fpath.read_text(encoding="utf-8")
|
|
assert text.startswith("#usda 1.0"), f"{fpath} missing #usda 1.0 header"
|
|
assert 'metersPerUnit = 1.0' in text
|
|
assert 'upAxis = "Z"' in text
|
|
assert "def Xform" in text
|
|
assert "color3f[] primvars:displayColor" in text
|