25 lines
814 B
Python
25 lines
814 B
Python
from medimesh.scenario import run_toy_scenario
|
|
from medimesh.solver import DistributedAllocator, HumanitarianPolicy, SiteState
|
|
|
|
|
|
def test_allocator_respects_supply_and_bounds() -> None:
|
|
allocator = DistributedAllocator(iterations=6)
|
|
sites = [
|
|
SiteState("a", "north", 10, 12, minimum_service=3),
|
|
SiteState("b", "south", 5, 8, minimum_service=2),
|
|
]
|
|
|
|
result = allocator.allocate(sites, total_available=9.0, policy=HumanitarianPolicy())
|
|
|
|
assert round(result.total_allocated, 4) <= 9.0
|
|
assert result.allocations["a"] >= 3
|
|
assert result.allocations["b"] >= 2
|
|
|
|
|
|
def test_toy_scenario_runs_end_to_end() -> None:
|
|
outcome = run_toy_scenario()
|
|
|
|
assert outcome["ledger_verified"] is True
|
|
assert "hospital-a" in outcome["allocation"]
|
|
assert outcome["registry_nodes"]
|