mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 10:51:13 +00:00
set_element_value for enums - add a test
This commit is contained in:
@@ -29,6 +29,7 @@ import ifcopenshell.api.geometry
|
|||||||
import ifcopenshell.api.aggregate
|
import ifcopenshell.api.aggregate
|
||||||
import ifcopenshell.api.group
|
import ifcopenshell.api.group
|
||||||
import ifcopenshell.api.sequence
|
import ifcopenshell.api.sequence
|
||||||
|
import ifcopenshell.util.element
|
||||||
import ifcopenshell.util.selector as subject
|
import ifcopenshell.util.selector as subject
|
||||||
import ifcopenshell.util.placement
|
import ifcopenshell.util.placement
|
||||||
import ifcopenshell.util.pset
|
import ifcopenshell.util.pset
|
||||||
@@ -405,3 +406,22 @@ class TestSetElementValuePredefinedType(test.bootstrap.IFC4):
|
|||||||
assert element_type.ElementType == "FOOBAR"
|
assert element_type.ElementType == "FOOBAR"
|
||||||
assert element.PredefinedType == None
|
assert element.PredefinedType == None
|
||||||
assert element.ObjectType == 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")
|
||||||
|
|||||||
Reference in New Issue
Block a user