Coverage for backend/django/core/auxiliary/methods/custom_property_packages/create_compound.py: 100%
7 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-07-22 05:22 +0000
1from ...models.FlowsheetState import FlowsheetState
2from ...models.CustomPropertyPackage import CustomCompound, CompoundProperty, CompoundPropertyEnum
4def add_compound(flowsheet_state: FlowsheetState, name: str) -> CustomCompound:
5 """
6 Creates the compound, and adds all the properties the compound needs.
7 """
8 compound = CustomCompound.objects.create(
9 flowsheet_state=flowsheet_state,
10 name=name,
11 )
13 # add the properties for this compound.
14 properties = [
15 CompoundProperty(
16 flowsheet_state=flowsheet_state,
17 compound=compound,
18 compound_property_key=key,
19 )
20 for key in CompoundPropertyEnum.values
21 ]
22 CompoundProperty.objects.bulk_create(properties)
23 return compound