Fix failing tests in preparation for release.

This commit is contained in:
Dion Moult
2023-05-06 11:05:13 +10:00
parent 34d947c51f
commit 1fb6dac6fb
12 changed files with 88 additions and 62 deletions
+7 -7
View File
@@ -312,13 +312,13 @@ def update_drawing_name(ifc, drawing_tool, drawing=None, name=None):
if drawing_tool.does_file_exist(resolved_old_location):
drawing_tool.move_file(resolved_old_location, ifc.resolve_uri(new_location))
for reference in drawing_tool.get_references_with_location(old_location):
ifc.run("document.edit_reference", reference=reference, attributes={"Location": new_location})
sheet = drawing_tool.get_reference_document(reference)
if not sheet:
uri = ifc.resolve_uri(drawing_tool.get_document_uri(sheet, "LAYOUT"))
if drawing_tool.does_file_exist(uri):
drawing_tool.update_embedded_svg_location(uri, old_location, new_location)
for reference in drawing_tool.get_references_with_location(old_location):
ifc.run("document.edit_reference", reference=reference, attributes={"Location": new_location})
sheet = drawing_tool.get_reference_document(reference)
if sheet:
uri = ifc.resolve_uri(drawing_tool.get_document_uri(sheet, "LAYOUT"))
if drawing_tool.does_file_exist(uri):
drawing_tool.update_embedded_svg_location(uri, old_location, new_location)
def add_annotation(ifc, collector, drawing_tool, drawing=None, object_type=None):
+1
View File
@@ -314,6 +314,7 @@ class Drawing:
def show_decorations(cls): pass
def sync_object_placement(cls, obj): pass
def synchronise_ifc_and_text_attributes(cls, obj): pass
def update_embedded_svg_location(cls, uri, old_location, new_location): pass
def update_text_size_pset(cls, obj): pass
def update_text_value(cls, obj): pass
+2 -1
View File
@@ -1457,7 +1457,8 @@ class Drawing(blenderbim.core.tool.Drawing):
drawing = tool.Ifc.get_entity(camera)
# Running operators is much more efficient in this scenario than looping through each element
bpy.ops.object.hide_view_clear()
if not bpy.app.background:
bpy.ops.object.hide_view_clear()
filtered_elements = cls.get_drawing_elements(drawing) | cls.get_drawing_spaces(drawing)
hidden_objs = [o for o in bpy.context.visible_objects if tool.Ifc.get_entity(o) not in filtered_elements]
@@ -23,7 +23,7 @@ Scenario: Create drawing
And I press "bim.add_drawing"
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
And I set "scene.DocProperties.active_drawing_index" to "0"
And I press "bim.activate_view(drawing={drawing})"
And I press "bim.activate_drawing(drawing={drawing})"
When I press "bim.create_drawing"
Then nothing happens
@@ -41,7 +41,7 @@ Scenario: Create drawing after deleting a duplicated object
And I press "bim.add_drawing"
And the variable "drawing" is "IfcStore.get_file().by_type('IfcAnnotation')[0].id()"
And I set "scene.DocProperties.active_drawing_index" to "0"
And I press "bim.activate_view(drawing={drawing})"
And I press "bim.activate_drawing(drawing={drawing})"
And I press "bim.create_drawing"
And the object "IfcWall/Cube" is selected
And I press "object.delete(use_global=False)"
@@ -194,8 +194,8 @@ Scenario: Change the height of a wall
And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}"
And I press "bim.hotkey(hotkey='S_A')"
And the object "IfcWall/Wall" is selected
And I set "scene.BIMModelProperties.extrusion_depth" to "2000.0"
When I press "bim.change_extrusion_depth(depth=2000.0)"
And I set "scene.BIMModelProperties.extrusion_depth" to "2.0"
When I press "bim.change_extrusion_depth(depth=2.0)"
Then the object "IfcWall/Wall" dimensions are "1,0.1,2"
Scenario: Change the length of a wall
@@ -206,8 +206,8 @@ Scenario: Change the length of a wall
And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}"
And I press "bim.hotkey(hotkey='S_A')"
And the object "IfcWall/Wall" is selected
And I set "scene.BIMModelProperties.length" to "2000.0"
When I press "bim.change_layer_length(length=2000.0)"
And I set "scene.BIMModelProperties.length" to "2.0"
When I press "bim.change_layer_length(length=2.0)"
Then the object "IfcWall/Wall" dimensions are "2,0.1,3"
Scenario: Flip a wall
@@ -438,8 +438,8 @@ Scenario: Change the length of a beam
And I set "scene.BIMModelProperties.relating_type_id" to "{element_type}"
And I press "bim.hotkey(hotkey='S_A')"
And the object "IfcBeam/Beam" is selected
And I set "scene.BIMModelProperties.extrusion_depth" to "2000.0"
When I press "bim.change_profile_depth(depth=2000.0)"
And I set "scene.BIMModelProperties.extrusion_depth" to "2.0"
When I press "bim.change_profile_depth(depth=2.0)"
Then the object "IfcBeam/Beam" dimensions are "0.1,0.2,2"
Scenario: Rotate a beam by 90 degrees
+3 -4
View File
@@ -47,7 +47,7 @@ Scenario: Execute qto method - side formwork areas
And I press "bim.execute_qto_method"
Then "scene.BIMQtoProperties.qto_result" is "16.0"
Scenario: Execute assign_objects_base_qto
Scenario: Assign objects base qto
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
@@ -55,7 +55,7 @@ Scenario: Execute qto method - side formwork areas
When I press "bim.assign_objects_base_qto"
Then "active_object.PsetProperties.qto_name" is "Qto_WallBaseQuantities"
Scenario: Execute calculate_all_quantities
Scenario: Calculate all quantities
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
@@ -65,5 +65,4 @@ Scenario: Execute calculate_all_quantities
And I press "bim.enable_pset_editing(pset_id={qset_id}, obj='IfcWall/Cube', obj_type='Object')"
And I press "bim.disable_pset_editing(obj='IfcWall/Cube', obj_type='Object')"
Then "active_object.PsetProperties.qto_name" is "Qto_WallBaseQuantities"
Then "active_object.PsetProperties.properties['Length'].metadata.float_value" is "2.0"
Then "active_object.PsetProperties.properties['Length'].metadata.float_value" is "2000.0"
+2 -2
View File
@@ -25,8 +25,8 @@ Scenario: Unlink object
And I press "bim.add_material"
When I press "bim.unlink_object(obj='IfcWall/Cube')"
Then the object "Cube" is not an IFC element
And the material "Material" is not an IFC material
And the material "Material" is not an IFC style
And the material "Material" is an IFC style
And the material "Material.001" is not an IFC style
Scenario: Copy class
Given an empty IFC project
+22 -11
View File
@@ -431,8 +431,9 @@ def the_object_name_is_an_ifc_class(name, ifc_class):
@then(parsers.parse('the object "{name}" is not an IFC element'))
def the_object_name_is_not_an_ifc_element(name):
id = the_object_name_exists(name).BIMObjectProperties.ifc_definition_id
assert id == 0, f"The ID is {id}"
obj = the_object_name_exists(name)
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
assert ifc_definition_id == 0, f"The object {obj} has an ID of {ifc_definition_id}"
@then(parsers.parse('the object "{name}" has no data'))
@@ -447,21 +448,31 @@ def the_object_name_is_not_an_ifc_element(name):
@then(parsers.parse('the material "{name}" is an IFC material'))
def the_material_name_is_not_an_ifc_material(name):
id = the_material_name_exists(name).BIMObjectProperties.ifc_definition_id
assert id != 0, f"The ID is {id}"
def the_material_name_is_an_ifc_material(name):
obj = the_material_name_exists(name)
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
assert ifc_definition_id != 0, f"The material {obj} has no ID: {ifc_definition_id}"
@then(parsers.parse('the material "{name}" is not an IFC material'))
def the_material_name_is_not_an_ifc_material(name):
id = the_material_name_exists(name).BIMObjectProperties.ifc_definition_id
assert id == 0, f"The ID is {id}"
obj = the_material_name_exists(name)
ifc_definition_id = obj.BIMObjectProperties.ifc_definition_id
assert ifc_definition_id == 0, f"The material {obj} has an ID of {ifc_definition_id}"
@then(parsers.parse('the material "{name}" is an IFC style'))
def the_material_name_is_an_ifc_style(name):
obj = the_material_name_exists(name)
ifc_definition_id = obj.BIMMaterialProperties.ifc_style_id
assert ifc_definition_id != 0, f"The material {obj} has a style ID of {ifc_definition_id}"
@then(parsers.parse('the material "{name}" is not an IFC style'))
def the_material_name_is_not_an_ifc_material(name):
id = the_material_name_exists(name).BIMMaterialProperties.ifc_style_id
assert id == 0, f"The ID is {id}"
def the_material_name_is_not_an_ifc_style(name):
obj = the_material_name_exists(name)
ifc_definition_id = obj.BIMMaterialProperties.ifc_style_id
assert ifc_definition_id == 0, f"The material {obj} has a style ID of {ifc_definition_id}"
@then(parsers.parse('the material "{name}" colour is "{colour}"'))
@@ -636,7 +647,7 @@ def the_object_name_dimensions_are_dimensions(name, dimensions):
actual_dimensions = list(the_object_name_exists(name).dimensions)
expected_dimensions = [float(co) for co in dimensions.split(",")]
for i, number in enumerate(actual_dimensions):
assert is_x(number, expected_dimensions[i])
assert is_x(number, expected_dimensions[i]), f"Expected {actual_dimensions[i]} but got {number}"
@then(parsers.parse('the object "{name}" top right corner is at "{location}"'))
+18
View File
@@ -391,6 +391,7 @@ class TestUpdateDrawingName:
ifc.run("document.edit_information", information="information", attributes={"Name": "name"}).should_be_called()
drawing.get_reference_location("reference").should_be_called().will_return("old_location")
drawing.get_default_drawing_path("name").should_be_called().will_return("new_location")
ifc.run(
"document.edit_reference", reference="reference", attributes={"Location": "new_location"}
).should_be_called()
@@ -399,6 +400,23 @@ class TestUpdateDrawingName:
ifc.resolve_uri("new_location").should_be_called().will_return("new_uri")
drawing.move_file("old_uri", "new_uri").should_be_called()
drawing.get_references_with_location("old_location").should_be_called().will_return(
["reference_with_old_location"]
)
ifc.run(
"document.edit_reference", reference="reference_with_old_location", attributes={"Location": "new_location"}
).should_be_called()
drawing.get_reference_document("reference_with_old_location").should_be_called().will_return(
"sheet_with_old_location"
)
drawing.get_document_uri("sheet_with_old_location", "LAYOUT").should_be_called().will_return(
"relative_layout_uri"
)
ifc.resolve_uri("relative_layout_uri").should_be_called().will_return("absolute_layout_uri")
drawing.does_file_exist("absolute_layout_uri").should_be_called().will_return(True)
drawing.update_embedded_svg_location("absolute_layout_uri", "old_location", "new_location").should_be_called()
subject.update_drawing_name(ifc, drawing, drawing="drawing", name="name")
+2 -2
View File
@@ -135,8 +135,8 @@ class TestGetRepresentationContext(NewFile):
class TestIsElementA(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
assert subject.is_a(ifc.createIfcWall(), "IfcSlab") is False
assert subject.is_a(ifc.createIfcOpeningElement(), "IfcOpeningElement") is True
assert subject.is_element_a(ifc.createIfcWall(), "IfcSlab") is False
assert subject.is_element_a(ifc.createIfcOpeningElement(), "IfcOpeningElement") is True
class TestLinkObjectData(NewFile):