feat(phase-9): implement layout variations, pareto fleet optimization, and final demonstration
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
"""Unit tests for the end-to-end digital twin final demonstration workflow."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from warehouse_twin.demo.demo_runner import (
|
||||
FinalDemoConfig,
|
||||
FinalDemoResult,
|
||||
FinalDemoRunner,
|
||||
)
|
||||
|
||||
|
||||
def test_final_demo_config_initialization(tmp_path: Path):
|
||||
"""Verify FinalDemoConfig default values and quick mode adjustments."""
|
||||
cfg = FinalDemoConfig(quick_mode=True, output_dir=tmp_path / "demo")
|
||||
assert cfg.quick_mode is True
|
||||
assert cfg.duration_seconds <= 300.0
|
||||
|
||||
standard_cfg = FinalDemoConfig(quick_mode=False)
|
||||
assert standard_cfg.duration_seconds == 3600.0
|
||||
|
||||
|
||||
def test_final_demo_runner_execution(project_config_dir: Path, tmp_path: Path):
|
||||
"""Verify end-to-end demonstration workflow produces all expected artifacts."""
|
||||
demo_out = tmp_path / "demonstration"
|
||||
usd_out = tmp_path / "scenes" / "warehouse_final_demo.usda"
|
||||
|
||||
cfg = FinalDemoConfig(
|
||||
duration_seconds=90.0,
|
||||
seed=42,
|
||||
output_dir=demo_out,
|
||||
usd_output_path=usd_out,
|
||||
export_usd=True,
|
||||
export_svg=True,
|
||||
quick_mode=True,
|
||||
)
|
||||
|
||||
runner = FinalDemoRunner(project_config_dir)
|
||||
res = runner.run_demonstration(cfg)
|
||||
|
||||
# 1. Verification of execution results
|
||||
assert res.baseline_result is not None
|
||||
assert res.optimized_result is not None
|
||||
assert res.evaluation is not None
|
||||
assert res.evaluation.overall_score > 0.0
|
||||
|
||||
# 2. Layout & Pareto results
|
||||
assert res.layout_results is not None
|
||||
assert len(res.layout_results.comparison_table) >= 2
|
||||
assert res.pareto_results is not None
|
||||
assert len(res.pareto_results.all_points) >= 2
|
||||
|
||||
# 3. Artifact files
|
||||
assert res.markdown_report_path.exists()
|
||||
assert res.markdown_report_path.stat().st_size > 500
|
||||
|
||||
assert res.summary_json_path.exists()
|
||||
with open(res.summary_json_path, "r", encoding="utf-8") as f:
|
||||
data = json.load(f)
|
||||
assert "evaluation" in data
|
||||
assert "layout_comparison" in data
|
||||
|
||||
if res.svg_comparison_path:
|
||||
assert res.svg_comparison_path.exists()
|
||||
assert "<svg" in res.svg_comparison_path.read_text(encoding="utf-8")
|
||||
|
||||
if res.usd_stage_path:
|
||||
assert res.usd_stage_path.exists()
|
||||
usd_text = res.usd_stage_path.read_text(encoding="utf-8")
|
||||
assert "#usda 1.0" in usd_text
|
||||
|
||||
# 4. Result serialization
|
||||
d = res.to_dict()
|
||||
assert "evaluation" in d
|
||||
assert "markdown_report" in d
|
||||
assert "summary_json" in d
|
||||
Reference in New Issue
Block a user