mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Tuning feature tests
This commit is contained in:
@@ -8,9 +8,9 @@ Scenario: Add type instance - add from a mesh
|
||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
|
||||
And I press "bim.assign_class"
|
||||
And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
|
||||
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType"
|
||||
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
|
||||
And I set "scene.BIMModelProperties.relating_type" to "{cube}"
|
||||
And I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
|
||||
When I press "bim.add_type_instance"
|
||||
Then the object "IfcWall/Wall" exists
|
||||
|
||||
@@ -21,9 +21,9 @@ Scenario: Add type instance - add from an empty
|
||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
|
||||
And I press "bim.assign_class"
|
||||
And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
|
||||
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType"
|
||||
And the variable "empty" is "{ifc}.by_type('IfcWallType')[0].id()"
|
||||
And I set "scene.BIMModelProperties.relating_type" to "{empty}"
|
||||
And I set "scene.BIMModelProperties.constr_type_id" to "{empty}"
|
||||
When I press "bim.add_type_instance"
|
||||
Then the object "IfcWall/Wall" exists
|
||||
|
||||
@@ -34,9 +34,9 @@ Scenario: Add type instance - add a mesh where existing instances have changed c
|
||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
|
||||
And I press "bim.assign_class"
|
||||
And I set "scene.BIMModelProperties.ifc_class" to "IfcWallType"
|
||||
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType"
|
||||
And the variable "cube" is "{ifc}.by_type('IfcWallType')[0].id()"
|
||||
And I set "scene.BIMModelProperties.relating_type" to "{cube}"
|
||||
And I set "scene.BIMModelProperties.constr_type_id" to "{cube}"
|
||||
And I press "bim.add_type_instance"
|
||||
And the object "IfcWall/Wall" data is a "Tessellation" representation of "Model/Body/MODEL_VIEW"
|
||||
And the object "IfcWall/Wall" is selected
|
||||
@@ -48,18 +48,22 @@ Scenario: Add type instance - add a mesh where existing instances have changed c
|
||||
Then the object "IfcWall/Wall" data is a "Annotation2D" representation of "Plan/Annotation/PLAN_VIEW"
|
||||
And the object "IfcWall/Wall.001" data is a "Annotation2D" representation of "Plan/Annotation/PLAN_VIEW"
|
||||
|
||||
Scenario: Assetize one object
|
||||
Given I load the demo construction library
|
||||
And I set "scene.BIMModelProperties.constr_class" to "IfcBeamType"
|
||||
And I set "scene.BIMModelProperties.constr_class" to "DEMO1"
|
||||
When I make an asset from the selected construction type
|
||||
Scenario: Preview one type on the Construction Type Browser
|
||||
Given an empty IFC project
|
||||
And I load the demo construction library
|
||||
When I display the Construction Type Browser
|
||||
And I preview only one asset on the Construction Type Browser
|
||||
And I set "scene.BIMModelProperties.constr_class_browser" to "IfcBeamType"
|
||||
And I set "scene.BIMModelProperties.constr_type_browser" to "DEMO1"
|
||||
Then the object "IfcBeam/Beam" does not exist
|
||||
And the construction type "IfcBeamType"/"DEMO1" has a preview
|
||||
|
||||
Scenario: Assetize one class
|
||||
Given I load the demo construction library
|
||||
And I set "scene.BIMModelProperties.constr_class" to "IfcWallType"
|
||||
When I make assets from the selected construction class
|
||||
Scenario: Preview one class on the Construction Type Browser
|
||||
Given an empty IFC project
|
||||
And I load the demo construction library
|
||||
When I display the Construction Type Browser
|
||||
And I preview all available assets on the Construction Type Browser
|
||||
And I set "scene.BIMModelProperties.constr_class_browser" to "IfcWallType"
|
||||
Then objects starting with "IfcWall/" do not exist
|
||||
And all construction types for "IfcWallType" have a preview
|
||||
|
||||
|
||||
@@ -261,19 +261,6 @@ def the_object_name_exists(name) -> bpy.types.Object:
|
||||
assert False, f'The object "{name}" does not exist'
|
||||
return obj
|
||||
|
||||
@then(parsers.parse('the object "{name}" does not exist'))
|
||||
def the_object_name_not_exists(name):
|
||||
obj = bpy.data.objects.get(name)
|
||||
if obj:
|
||||
assert False, f'The object "{name}" exists'
|
||||
assert True
|
||||
|
||||
@then(parsers.parse('objects starting with "{name}" do not exist'))
|
||||
def objects_not_exist_starting_with(name):
|
||||
objs = [obj for obj in bpy.data.objects if obj.name.startswith(name)]
|
||||
if len(objs) > 0:
|
||||
assert False, f'{len(objs)} objects starting with "{name}" exist'
|
||||
assert True
|
||||
|
||||
@then(parsers.parse('the object "{name1}" and "{name2}" are different elements'))
|
||||
def the_object_name1_and_name2_are_different_elements(name1, name2):
|
||||
@@ -520,7 +507,16 @@ def the_collection_name1_is_in_the_collection_name2(name1, name2):
|
||||
|
||||
@then(parsers.parse('the object "{name}" does not exist'))
|
||||
def the_object_name_does_not_exist(name):
|
||||
assert bpy.data.objects.get(name) is None, "Object exists"
|
||||
obj = bpy.data.objects.get(name)
|
||||
assert obj is None or len(obj.users_collection) == 0, "Object exists"
|
||||
|
||||
|
||||
@then(parsers.parse('objects starting with "{name}" do not exist'))
|
||||
def objects_not_exist_starting_with(name):
|
||||
objs = [obj for obj in bpy.data.objects if obj.name.startswith(name) and len(obj.users_collection) > 0]
|
||||
if len(objs) > 0:
|
||||
assert False, f'{len(objs)} objects starting with "{name}" exist'
|
||||
assert True
|
||||
|
||||
|
||||
@then(parsers.parse('the object "{name}" is at "{location}"'))
|
||||
@@ -579,7 +575,7 @@ def the_object_name_has_no_modifiers(name):
|
||||
|
||||
@then(parsers.parse('the construction type "{constr_class}"/"{constr_type}" has a preview'))
|
||||
def the_construction_type_has_a_preview(constr_class, constr_type):
|
||||
if "preview_constr_types" not in AuthoringData:
|
||||
if "preview_constr_types" not in AuthoringData.data:
|
||||
assert False, 'There are no previews loaded'
|
||||
preview_constr_types = AuthoringData.data["preview_constr_types"]
|
||||
if constr_class not in preview_constr_types:
|
||||
@@ -593,7 +589,7 @@ def the_construction_type_has_a_preview(constr_class, constr_type):
|
||||
if 'icon_id' not in preview_data:
|
||||
assert False, f'Construction type {constr_class}/{constr_type} has a preview, but no assigned icon_id'
|
||||
icon_id = preview_data["icon_id"]
|
||||
if type(icon_id) is not int:
|
||||
if not isinstance(icon_id, int):
|
||||
assert False, f'Construction type {constr_class}/{constr_type} has an invalid icon_id {icon_id}'
|
||||
if icon_id == 0:
|
||||
assert False, f'Construction type {constr_class}/{constr_type} has the default null value for icon_id'
|
||||
@@ -602,7 +598,7 @@ def the_construction_type_has_a_preview(constr_class, constr_type):
|
||||
|
||||
@then(parsers.parse('all construction types for "{constr_class}" have a preview'))
|
||||
def all_construction_types_have_a_preview(constr_class):
|
||||
if "preview_constr_types" not in AuthoringData:
|
||||
if "preview_constr_types" not in AuthoringData.data:
|
||||
assert False, 'There are no previews loaded'
|
||||
preview_constr_types = AuthoringData.data["preview_constr_types"]
|
||||
if constr_class not in preview_constr_types:
|
||||
@@ -615,17 +611,32 @@ def all_construction_types_have_a_preview(constr_class):
|
||||
@given("I load the demo construction library")
|
||||
@when("I load the demo construction library")
|
||||
def i_add_a_construction_library():
|
||||
lib_path = '../../blenderbim/bim/data/libraries/IFC4 Demo Library.ifc'
|
||||
lib_path = './blenderbim/bim/data/libraries/IFC4 Demo Library.ifc'
|
||||
bpy.ops.bim.select_library_file(filepath=lib_path, append_all=True)
|
||||
|
||||
|
||||
@given("I make an asset from the selected construction type")
|
||||
@when("I make an asset from the selected construction type")
|
||||
def i_assetize_from_selected_constr_type():
|
||||
AuthoringData.assetize_constr_type_from_selection()
|
||||
@given("I display the Construction Type Browser")
|
||||
@when("I display the Construction Type Browser")
|
||||
def i_display_the_construction_type_browser():
|
||||
bpy.ops.bim.display_constr_types()
|
||||
|
||||
|
||||
@given("I make assets from the selected construction class")
|
||||
@when("I make assets from the selected construction class")
|
||||
def i_assetize_from_selected_constr_class():
|
||||
AuthoringData.assetize_constr_class()
|
||||
@given("I preview only one asset on the Construction Type Browser")
|
||||
@when("I preview only one asset on the Construction Type Browser")
|
||||
def i_preview_one_construction_type():
|
||||
bpy.context.scene.BIMModelProperties.unfold_relating_type = False
|
||||
|
||||
|
||||
@given("I preview all available assets on the Construction Type Browser")
|
||||
@when("I preview all available assets on the Construction Type Browser")
|
||||
def i_preview_all_construction_types():
|
||||
bpy.context.scene.BIMModelProperties.unfold_relating_type = True
|
||||
|
||||
|
||||
@given("I select the active construction type")
|
||||
@when("I select the active construction type")
|
||||
def i_select_the_active_construction_type():
|
||||
props = bpy.context.scene.BIMModelProperties
|
||||
bpy.ops.bim.select_construction_type(
|
||||
constr_class=props.constr_class_browser, constr_type_id=props.constr_type_id_browser
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user