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-03-26 20:57 +0000

1from ...models.Flowsheet import Flowsheet 

2from ...models.CustomPropertyPackage import CustomCompound, CompoundProperty, CompoundPropertyEnum 

3 

4def add_compound(flowsheet: Flowsheet, name: str) -> CustomCompound: 

5 """ 

6 Creates the compound, and adds all the properties the compound needs. 

7 """ 

8 compound = CustomCompound.objects.create(flowsheet=flowsheet, name=name) 

9 

10 # add the properties for this compound. 

11 properties = [ 

12 CompoundProperty( 

13 flowsheet=flowsheet, 

14 compound=compound, 

15 compound_property_key=key, 

16 ) 

17 for key in CompoundPropertyEnum.values 

18 ] 

19 CompoundProperty.objects.bulk_create(properties) 

20 return compound 

21