mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 13:28:19 +00:00
Fix #4893. IfcTester now requires lowercase booleans or 0/1.
This changed on May 5: https://github.com/buildingSMART/IDS/issues/290
This commit is contained in:
@@ -39,9 +39,9 @@ def cast_to_value(from_value, to_value):
|
|||||||
# We do not cast to int because 42.0 == 42 and 42.3 != 42
|
# We do not cast to int because 42.0 == 42 and 42.3 != 42
|
||||||
return float(from_value)
|
return float(from_value)
|
||||||
elif target_type == "bool":
|
elif target_type == "bool":
|
||||||
if from_value == "TRUE":
|
if from_value in ("true", "1"):
|
||||||
return True
|
return True
|
||||||
elif from_value == "FALSE":
|
elif from_value in ("false", "0"):
|
||||||
return False
|
return False
|
||||||
return builtins.__dict__[target_type](from_value)
|
return builtins.__dict__[target_type](from_value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
@@ -557,14 +557,19 @@ class TestAttribute:
|
|||||||
expected=False,
|
expected=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
facet = Attribute(name="IsMilestone", value="TRUE")
|
facet = Attribute(name="IsMilestone", value="true")
|
||||||
ifc = ifcopenshell.file()
|
ifc = ifcopenshell.file()
|
||||||
element = ifc.createIfcTask(IsMilestone=False)
|
element = ifc.createIfcTask(IsMilestone=False)
|
||||||
run("Booleans must be specified as uppercase strings 1/3", facet=facet, inst=element, expected=False)
|
run("Booleans must be specified as lowercase strings 1/3", facet=facet, inst=element, expected=False)
|
||||||
facet = Attribute(name="IsMilestone", value="FALSE")
|
facet = Attribute(name="IsMilestone", value="false")
|
||||||
run("Booleans must be specified as uppercase strings 2/3", facet=facet, inst=element, expected=True)
|
run("Booleans must be specified as lowercase strings 2/3", facet=facet, inst=element, expected=True)
|
||||||
facet = Attribute(name="IsMilestone", value="False")
|
facet = Attribute(name="IsMilestone", value="False")
|
||||||
run("Booleans must be specified as uppercase strings 2/3", facet=facet, inst=element, expected=False)
|
run("Booleans must be specified as lowercase strings 2/3", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
|
facet = Attribute(name="IsMilestone", value="0")
|
||||||
|
run("Booleans can be specified as a 0 or 1 1/2", facet=facet, inst=element, expected=True)
|
||||||
|
facet = Attribute(name="IsMilestone", value="1")
|
||||||
|
run("Booleans can be specified as a 0 or 1 2/2", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
facet = Attribute(name="EditionDate", value="2022-01-01")
|
facet = Attribute(name="EditionDate", value="2022-01-01")
|
||||||
ifc = ifcopenshell.file()
|
ifc = ifcopenshell.file()
|
||||||
@@ -982,14 +987,19 @@ class TestProperty:
|
|||||||
)
|
)
|
||||||
run("Floating point numbers are compared with a 1e-6 tolerance 4/4", facet=facet, inst=element, expected=False)
|
run("Floating point numbers are compared with a 1e-6 tolerance 4/4", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="TRUE", dataType="IFCBOOLEAN")
|
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="true", dataType="IFCBOOLEAN")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcBoolean(False)})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcBoolean(False)})
|
||||||
run("Booleans must be specified as uppercase strings 1/3", facet=facet, inst=element, expected=False)
|
run("Booleans must be specified as uppercase strings 1/3", facet=facet, inst=element, expected=False)
|
||||||
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="FALSE", dataType="IFCBOOLEAN")
|
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="false", dataType="IFCBOOLEAN")
|
||||||
run("Booleans must be specified as uppercase strings 2/3", facet=facet, inst=element, expected=True)
|
run("Booleans must be specified as uppercase strings 2/3", facet=facet, inst=element, expected=True)
|
||||||
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="False", dataType="IFCBOOLEAN")
|
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="False", dataType="IFCBOOLEAN")
|
||||||
run("Booleans must be specified as uppercase strings 3/3", facet=facet, inst=element, expected=False)
|
run("Booleans must be specified as uppercase strings 3/3", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
|
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="0", dataType="IFCBOOLEAN")
|
||||||
|
run("Booleans can be specified as as a 0 or 1 1/2", facet=facet, inst=element, expected=True)
|
||||||
|
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="1", dataType="IFCBOOLEAN")
|
||||||
|
run("Booleans can be specified as as a 0 or 1 2/2", facet=facet, inst=element, expected=False)
|
||||||
|
|
||||||
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="2022-01-01", dataType="IFCDATE")
|
facet = Property(propertySet="Foo_Bar", baseName="Foo", value="2022-01-01", dataType="IFCDATE")
|
||||||
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcDate("2022-01-01")})
|
ifcopenshell.api.run("pset.edit_pset", ifc, pset=pset, properties={"Foo": ifc.createIfcDate("2022-01-01")})
|
||||||
run("Dates are treated as strings 1/2", facet=facet, inst=element, expected=True)
|
run("Dates are treated as strings 1/2", facet=facet, inst=element, expected=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user