import pytest from gridresilience_studio.core import Object, Morphism, PlanDelta, DeltaStore from gridresilience_studio.offline_sync import DeltaSyncEngine def test_build_sample_world_and_delta_sync_basic(): # Build a tiny world and ensure delta can be applied and snapshot produced ds = DeltaStore() ds.add_object(Object(id="DER1", type="DER", properties={"rated_kW": 500})) ds.add_object(Object(id="LOAD1", type="Load", properties={"critical": True})) ds.add_morphism(Morphism(id="SIG1", source="DER1", target="LOAD1", signals={"voltage": 1.0})) delta = PlanDelta(delta_id="D1", islanded=True, actions=[{"type": "island", "target": "LOAD1"}]) ds.add_delta(delta) engine = DeltaSyncEngine(store=ds) engine.apply_delta(delta) snap = engine.snapshot() assert len(snap) == 1 assert snap[0].delta_id == "D1"