diff --git a/src/ifcopenshell-python/test/util/test_selector.py b/src/ifcopenshell-python/test/util/test_selector.py index ed2f93448d..56f52b2077 100644 --- a/src/ifcopenshell-python/test/util/test_selector.py +++ b/src/ifcopenshell-python/test/util/test_selector.py @@ -29,6 +29,7 @@ import ifcopenshell.api.geometry import ifcopenshell.api.aggregate import ifcopenshell.api.group import ifcopenshell.api.sequence +import ifcopenshell.util.element import ifcopenshell.util.selector as subject import ifcopenshell.util.placement import ifcopenshell.util.pset @@ -405,3 +406,22 @@ class TestSetElementValuePredefinedType(test.bootstrap.IFC4): assert element_type.ElementType == "FOOBAR" assert element.PredefinedType == None assert element.ObjectType == None + + +class TestSetElementValueEnum(test.bootstrap.IFC4): + def test_setting_an_element_enum(self): + element = self.file.create_entity("IfcWindow") + pset = ifcopenshell.api.pset.add_pset(self.file, product=element, name="Pset_WallCommon") + ifcopenshell.api.pset.edit_pset(self.file, pset=pset, properties={"Status": ("NEW",)}) + subject.set_element_value(self.file, element, "Pset_WallCommon.Status", "DEMOLISH, OTHER") + + pset_data = ifcopenshell.util.element.get_pset(element, "Pset_WallCommon") + assert pset_data["Status"] == ["DEMOLISH", "OTHER"] + + # Wrong value for enum. + with pytest.raises(Exception): + subject.set_element_value(self.file, element, "Pset_WallCommon.Status", "NON_EXISTENT_VALUE") + + # String is using wrong concatenations tring and it should be identified as non-existent value. + with pytest.raises(Exception): + subject.set_element_value(self.file, element, "Pset_WallCommon.Status", "DEMOLISH,OTHER")