Skip to content

microgrid.engine.testing

For a client's own plant model: the contract every plant model keeps.

assert_plant_model_contract runs a plant model (extend.PlantModel) over a few synthetic days and raises AssertionError where it breaks what the port promises. It needs no test framework; call it from any.

It also runs the stored cost over the model (Storage.stored_per_kwh), the price a client's own model gets by default.

Pure: no I/O.

assert_plant_model_contract

assert_plant_model_contract(plant: PlantModel) -> None

What every plant model keeps, whatever its topology, with a battery or without, with PV or without. Raises AssertionError naming what broke.

Only what the port promises: no conversion (a DC array loses some PV on its way to an AC load) and no dispatch (more load can raise a dynamic top-up target, so the battery need not end lower); and the stored cost, the price's default rule, over its projections (Storage.stored_per_kwh).