37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from idea154_civicmesh_studio_federated.registry import (
|
|
AdapterContext,
|
|
GISLayerAdapter,
|
|
GraphOfContractsRegistry,
|
|
WaterPumpControllerAdapter,
|
|
WeatherForecastAdapter,
|
|
)
|
|
|
|
|
|
def test_registry_routes_adapters():
|
|
registry = GraphOfContractsRegistry()
|
|
registry.register(GISLayerAdapter())
|
|
registry.register(WeatherForecastAdapter())
|
|
registry.register(WaterPumpControllerAdapter())
|
|
|
|
local_model = registry.route(
|
|
"gis-layer",
|
|
{
|
|
"energy_limit_kw": 12.0,
|
|
"features": [
|
|
{"properties": {"id": "light-1", "asset_type": "street-light", "capacity_kw": 1.0}},
|
|
{"properties": {"id": "pump-2", "asset_type": "pump", "capacity_m3": 3.5}},
|
|
],
|
|
},
|
|
AdapterContext(neighborhood_id="n-1"),
|
|
)
|
|
|
|
assert local_model.neighborhood_id == "n-1"
|
|
assert len(local_model.assets) == 2
|
|
|
|
|
|
def test_registry_compatibility_report_contains_versions():
|
|
registry = GraphOfContractsRegistry()
|
|
registry.register(GISLayerAdapter())
|
|
report = registry.compatibility_report()
|
|
assert report[0]["version"] == "1.0"
|