Add tests for sheet creation and drawing / sheet generation

This commit is contained in:
Dion Moult
2025-04-19 17:36:16 +10:00
parent b64dcfd4b8
commit df18108406
2 changed files with 87 additions and 14 deletions
+75 -3
View File
@@ -81,8 +81,8 @@ Scenario: Create drawing
When I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
And I click "OUTLINER_OB_CAMERA"
And I click "OUTPUT"
Then the drawing "PLAN_VIEW.svg" contains "cut"
And the drawing "PLAN_VIEW.svg" contains "IfcWall"
Then the file "{ifc_dir}/drawings/PLAN_VIEW.svg" should contain "cut"
And the file "{ifc_dir}/drawings/PLAN_VIEW.svg" should contain "IfcWall"
Scenario: Create drawing after deleting a duplicated object
Given an empty IFC project
@@ -239,4 +239,76 @@ Scenario: Create drawing - using shapely fill mode
And I set the "Fill Mode" property to "Shapely"
And I look at the "Drawings" panel
And I click "OUTPUT"
Then the drawing "MY STOREY PLAN.svg" contains "IfcWall material-null surface"
Then the file "{ifc_dir}/drawings/MY STOREY PLAN.svg" should contain "IfcWall material-null surface"
Scenario: Add sheet
Given an empty IFC project
And I save sample test files
And I look at the "Sheets" panel
And I click "IMPORT"
When I click "ADD"
Then the file "{ifc_dir}/layouts/A00 - UNTITLED.svg" should contain "titleblocks/A1.svg"
And the file "{ifc_dir}/layouts/A00 - UNTITLED.svg" should not contain "GRID NORTH"
Scenario: Create sheet
Given an empty IFC project
And I save sample test files
And I look at the "Sheets" panel
And I click "IMPORT"
And I click "ADD"
And I select the "UNTITLED" item in the "BIM_UL_sheets" list
When I click "OUTPUT"
Then the file "{ifc_dir}/sheets/A00 - UNTITLED.svg" should not contain "titleblocks/A1.svg"
And the file "{ifc_dir}/sheets/A00 - UNTITLED.svg" should contain "GRID NORTH"
And the file "{ifc_dir}/sheets/A00 - UNTITLED.svg" should not contain "IfcWall"
Scenario: Add drawing to sheet
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I look at the "Class" panel
And I set the "Products" property to "IfcElement"
And I set the "Class" property to "IfcWall"
And I click "Assign IFC Class"
And I save sample test files
And I look at the "Drawings" panel
And I click "IMPORT"
And I click "ADD"
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
And I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
And I click "OUTLINER_OB_CAMERA"
And I click "OUTPUT"
And I look at the "Sheets" panel
And I click "IMPORT"
And I click "ADD"
And the variable "sheet" is "tool.Ifc.get().by_type('IfcDocumentInformation')[-1].id()"
And I select the "UNTITLED" item in the "BIM_UL_sheets" list
And I press "bim.expand_sheet(sheet={sheet})"
When I click "IMAGE_PLANE"
Then I can select the "PLAN_VIEW.svg" item in the "BIM_UL_sheets" list
Scenario: Create sheet - with a drawing added to it
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I look at the "Class" panel
And I set the "Products" property to "IfcElement"
And I set the "Class" property to "IfcWall"
And I click "Assign IFC Class"
And I save sample test files
And I look at the "Drawings" panel
And I click "IMPORT"
And I click "ADD"
And I press "bim.expand_target_view(target_view='PLAN_VIEW')"
And I select the "PLAN_VIEW" item in the "BIM_UL_drawinglist" list
And I click "OUTLINER_OB_CAMERA"
And I click "OUTPUT"
And I look at the "Sheets" panel
And I click "IMPORT"
And I click "ADD"
And the variable "sheet" is "tool.Ifc.get().by_type('IfcDocumentInformation')[-1].id()"
And I select the "UNTITLED" item in the "BIM_UL_sheets" list
And I press "bim.expand_sheet(sheet={sheet})"
And I click "IMAGE_PLANE"
When I click "OUTPUT"
Then the file "{ifc_dir}/sheets/A00 - UNTITLED.svg" should contain "IfcWall"
+12 -11
View File
@@ -40,6 +40,7 @@ scenarios("feature")
variables = {
"cwd": Path.cwd().as_posix(),
"ifc_dir": os.path.join(Path.cwd().as_posix(), "test", "files", "temp"),
"ifc": "tool.Ifc.get()",
"pset_ifc": "IfcStore.pset_template_file",
"classification_ifc": "IfcStore.classification_file",
@@ -405,6 +406,7 @@ def the_name_list_has_total_items(name, total):
@given(parsers.parse('I select the "{item_name}" item in the "{list_name}" list'))
@when(parsers.parse('I select the "{item_name}" item in the "{list_name}" list'))
@then(parsers.parse('I can select the "{item_name}" item in the "{list_name}" list'))
def i_select_the_item_name_item_in_the_list_name_list(item_name, list_name):
assert panel_spy
panel_spy.refresh_spy()
@@ -1360,7 +1362,16 @@ def the_object_name_has_no_aggregate(name: str) -> None:
def the_file_name_should_contain_value(name, value):
name = replace_variables(name)
with open(name, "r") as f:
assert value in f.read()
content = f.read()
assert value in content, f"File {name} does not contain {value}:\n{content}"
@then(parsers.parse('the file "{name}" should not contain "{value}"'))
def the_file_name_should_contain_value(name, value):
name = replace_variables(name)
with open(name, "r") as f:
content = f.read()
assert value not in content, f"File {name} contains {value}:\n{content}"
@then(parsers.parse('the object "{name}" has no modifiers'))
@@ -1504,16 +1515,6 @@ def the_obj_layer_length_is_set_to(value):
bpy.ops.bim.change_layer_length(length=value)
@then(parsers.parse('the drawing "{filename}" contains "{text}"'))
def the_drawing_filename_contains_text(filename, text):
filepath = f"{variables['cwd']}/test/files/temp/drawings/{filename}"
with open(filepath, "r") as f:
content = f.read()
if text in content:
return True
assert False, f"Drawing {filename} does not contain {text}:\n{filepath}\n{content}"
# These definitions are not to be used in tests but simply in debugging failing tests