You can now load, unlink, and unload links.

This commit is contained in:
Dion Moult
2021-09-13 10:48:38 +10:00
parent 5cee2fb08a
commit 2dc6a3bcc6
6 changed files with 108 additions and 8 deletions
+10
View File
@@ -155,10 +155,18 @@ def the_object_name_is_in_the_collection_collection(name, collection):
assert collection in [c.name for c in the_object_name_exists(name).users_collection]
def the_object_name_is_not_in_the_collection_collection(name, collection):
assert collection not in [c.name for c in the_object_name_exists(name).users_collection]
def the_collection_name1_is_in_the_collection_name2(name1, name2):
assert bpy.data.collections.get(name2).children.get(name1)
def the_collection_name1_is_not_in_the_collection_name2(name1, name2):
assert not bpy.data.collections.get(name2).children.get(name1)
def the_object_name_is_placed_in_the_collection_collection(name, collection):
obj = the_object_name_exists(name)
[c.objects.unlink(obj) for c in obj.users_collection]
@@ -266,7 +274,9 @@ definitions = {
'the object "(.*)" is an "(.*)"': the_object_name_is_an_ifc_class,
'the object "(.*)" is not an IFC element': the_object_name_is_not_an_ifc_element,
'the object "(.*)" is in the collection "(.*)"': the_object_name_is_in_the_collection_collection,
'the object "(.*)" is not in the collection "(.*)"': the_object_name_is_not_in_the_collection_collection,
'the collection "(.*)" is in the collection "(.*)"': the_collection_name1_is_in_the_collection_name2,
'the collection "(.*)" is not in the collection "(.*)"': the_collection_name1_is_not_in_the_collection_name2,
"an IFC file exists": an_ifc_file_exists,
"an IFC file does not exist": an_ifc_file_does_not_exist,
'the object "(.*)" has a "(.*)" representation of "(.*)"': the_object_name_has_a_type_representation_of_context,
@@ -252,3 +252,38 @@ class TestLinkIFC(test.bim.bootstrap.NewFile):
And the object "IfcBuildingStorey/Ground Floor" exists
And the object "IfcBuildingStorey/Level 1" exists
"""
class TestUnloadLink(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_unloading_a_link(self):
return """
When I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
And I press "bim.unload_link(filepath='{cwd}/test/files/basic.blend')"
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.blend'].is_loaded" is "False"
And "scene.collection.children.get('IfcProject/My Project')" is "None"
"""
class TestLoadLink(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_loading_a_link(self):
return """
When I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
And I press "bim.unload_link(filepath='{cwd}/test/files/basic.blend')"
And I press "bim.load_link(filepath='{cwd}/test/files/basic.blend')"
Then "scene.BIMProjectProperties.links['{cwd}/test/files/basic.blend'].is_loaded" is "True"
And "scene.collection.children['IfcProject/My Project'].users" is "2"
"""
class TestUnlinkIFC(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_unlinking_an_ifc(self):
return """
When I press "bim.link_ifc(filepath='{cwd}/test/files/basic.blend')"
And I press "bim.unload_link(filepath='{cwd}/test/files/basic.blend')"
And I press "bim.unlink_ifc(filepath='{cwd}/test/files/basic.blend')"
Then "scene.BIMProjectProperties.links.get('{cwd}/test/files/basic.blend')" is "None"
And "scene.collection.children.get('IfcProject/My Project')" is "None"
"""
Binary file not shown.