feat(phase2): implement AMR robot state machine, task lifecycles, inventory catalog, and Phase 2 OpenUSD scene
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
"""Unit tests for simulation event schema and serialization."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import pytest
|
||||
|
||||
from warehouse_twin.domain.events import SimulationEvent, SimulationEventType
|
||||
|
||||
|
||||
def test_simulation_event_serialization():
|
||||
"""Verify SimulationEvent to_dict and to_jsonl formatting."""
|
||||
evt = SimulationEvent(
|
||||
event_id="evt_001",
|
||||
simulation_time=124.5678,
|
||||
event_type=SimulationEventType.TASK_ASSIGNED,
|
||||
entity_id="amr_light_01",
|
||||
task_id="task_ord_001",
|
||||
metadata={"priority": 1, "battery_pct": 98.5},
|
||||
)
|
||||
|
||||
data = evt.to_dict()
|
||||
assert data["event_id"] == "evt_001"
|
||||
assert data["simulation_time"] == 124.568
|
||||
assert data["event_type"] == "TASK_ASSIGNED"
|
||||
assert data["entity_id"] == "amr_light_01"
|
||||
assert data["task_id"] == "task_ord_001"
|
||||
assert data["metadata"]["priority"] == 1
|
||||
|
||||
jsonl_str = evt.to_jsonl()
|
||||
reparsed = json.loads(jsonl_str)
|
||||
assert reparsed["event_type"] == "TASK_ASSIGNED"
|
||||
assert reparsed["metadata"]["battery_pct"] == 98.5
|
||||
Reference in New Issue
Block a user