Coverage for backend/django/idaes_factory/adapters/dynamic_adapter.py: 100%
11 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-05-13 02:47 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-05-13 02:47 +0000
1from ahuora_builder_types.unit_model_schema import ValueArgSchema
3from .property_info_adapter import ValueAdapter
4from ..queryset_lookup import get_property, get_value_object
5from ahuora_builder_types import PropertySchema, PropertiesSchema, PropertyValueSchema
8class DynamicAdapter(ValueAdapter):
9 """
10 Returns True if the unit model has dynamics enabled, otherwise False.
11 """
13 def serialise(self, ctx, model) -> ValueArgSchema:
14 # If the flowsheet is not dynamic, return False
15 if not ctx.is_dynamic():
16 return ValueArgSchema(value=False)
17 # get the property from the unit model
18 property_set = model.properties
19 prop = get_property(property_set, "dynamics")
20 # serialise the property
21 return ValueArgSchema(value=prop.values.first().value == True)