| 209 | |
| 210 | |
| 211 | class TestImportUnitAttributes(NewFile): |
| 212 | def test_importing_derived_units(self): |
| 213 | tool.Ifc.set(ifc := ifcopenshell.file()) |
| 214 | unit = ifc.createIfcDerivedUnit() |
| 215 | unit.UnitType = "ANGULARVELOCITYUNIT" |
| 216 | unit.UserDefinedType = "UserDefinedType" |
| 217 | subject.import_unit_attributes(unit) |
| 218 | props = tool.Unit.get_unit_props() |
| 219 | assert props.unit_attributes["UnitType"].enum_value == "ANGULARVELOCITYUNIT" |
| 220 | assert props.unit_attributes["UserDefinedType"].string_value == "UserDefinedType" |
| 221 | |
| 222 | def test_importing_monetary_units(self): |
| 223 | tool.Ifc.set(ifc := ifcopenshell.file()) |
| 224 | unit = ifc.createIfcMonetaryUnit() |
| 225 | unit.Currency = "Currency" |
| 226 | subject.import_unit_attributes(unit) |
| 227 | props = tool.Unit.get_unit_props() |
| 228 | assert props.unit_attributes["Currency"].string_value == "Currency" |
| 229 | |
| 230 | def test_importing_monetary_units_ifc2x3(self): |
| 231 | tool.Ifc.set(ifc := ifcopenshell.file(schema="IFC2X3")) |
| 232 | unit = ifc.createIfcMonetaryUnit() |
| 233 | unit.Currency = "USD" |
| 234 | subject.import_unit_attributes(unit) |
| 235 | props = tool.Unit.get_unit_props() |
| 236 | assert props.unit_attributes["Currency"].enum_value == "USD" |
| 237 | |
| 238 | def test_importing_context_dependent_units(self): |
| 239 | ifc = ifcopenshell.file() |
| 240 | tool.Ifc.set(ifc) |
| 241 | unit = ifc.createIfcContextDependentUnit() |
| 242 | unit.UnitType = "ABSORBEDDOSEUNIT" |
| 243 | unit.Name = "Name" |
| 244 | unit.Dimensions = ifc.createIfcDimensionalExponents(1, 2, 3, 4, 5, 6, 7) |
| 245 | subject.import_unit_attributes(unit) |
| 246 | props = tool.Unit.get_unit_props() |
| 247 | assert props.unit_attributes["UnitType"].enum_value == "ABSORBEDDOSEUNIT" |
| 248 | assert props.unit_attributes["Name"].string_value == "Name" |
| 249 | assert props.unit_attributes["Dimensions"].string_value == "[1, 2, 3, 4, 5, 6, 7]" |
| 250 | |
| 251 | def test_importing_conversion_based_units(self): |
| 252 | ifc = ifcopenshell.file() |
| 253 | tool.Ifc.set(ifc) |
| 254 | unit = ifc.createIfcConversionBasedUnit() |
| 255 | unit.UnitType = "ABSORBEDDOSEUNIT" |
| 256 | unit.Name = "Name" |
| 257 | unit.Dimensions = ifc.createIfcDimensionalExponents(1, 2, 3, 4, 5, 6, 7) |
| 258 | subject.import_unit_attributes(unit) |
| 259 | props = tool.Unit.get_unit_props() |
| 260 | assert props.unit_attributes["UnitType"].enum_value == "ABSORBEDDOSEUNIT" |
| 261 | assert props.unit_attributes["Name"].string_value == "Name" |
| 262 | assert props.unit_attributes["Dimensions"].string_value == "[1, 2, 3, 4, 5, 6, 7]" |
| 263 | |
| 264 | def test_importing_conversion_based_with_offset_units(self): |
| 265 | ifc = ifcopenshell.file() |
| 266 | tool.Ifc.set(ifc) |
| 267 | unit = ifc.createIfcConversionBasedUnitWithOffset() |
| 268 | unit.UnitType = "ABSORBEDDOSEUNIT" |
no outgoing calls