Fix bug where syncing an object removed from the collection tree breaks.

This commit is contained in:
Dion Moult
2022-01-30 14:42:26 +11:00
parent bf9d46b506
commit c7428dd160
8 changed files with 71 additions and 43 deletions
+4 -4
View File
@@ -37,8 +37,8 @@ class TestImplementsTool(NewFile):
class TestAddBrick(NewFile):
def test_run(self):
BrickStore.graph = brickschema.Graph()
result = subject.add_brick("http://example.org/digitaltwin#", "https://brickschema.org/schema/Brick#Equipment")
assert "http://example.org/digitaltwin#" in result
result = subject.add_brick("https://example.org/digitaltwin#", "https://brickschema.org/schema/Brick#Equipment")
assert "https://example.org/digitaltwin#" in result
assert list(
BrickStore.graph.triples(
(URIRef(result), RDF.type, URIRef("https://brickschema.org/schema/Brick#Equipment"))
@@ -250,7 +250,7 @@ class TestGetConvertableBrickElements(NewFile):
class TestGetItemClass(NewFile):
def test_run(self):
TestLoadBrickFile().test_run()
assert subject.get_item_class("http://example.org/digitaltwin#floor") == "Floor"
assert subject.get_item_class("https://example.org/digitaltwin#floor") == "Floor"
class TestGetLibraryBrickReference(NewFile):
@@ -300,7 +300,7 @@ class TestImportBrickItems(NewFile):
brick = bpy.context.scene.BIMBrickProperties.bricks[0]
assert brick.name == "bldg"
assert brick.label == "My Building"
assert brick.uri == "http://example.org/digitaltwin#bldg"
assert brick.uri == "https://example.org/digitaltwin#bldg"
assert brick.total_items == 0
@@ -249,6 +249,14 @@ class TestAssign(NewFile):
class TestSync(NewFile):
def test_doing_nothing_if_the_object_has_no_collection(self):
bpy.ops.bim.create_project()
wall_obj = bpy.data.objects.new("Object", None)
wall_element = tool.Ifc.get().createIfcWall()
tool.Ifc.link(wall_element, wall_obj)
subject.sync(wall_obj)
assert not wall_obj.users_collection
def test_in_decomposition_mode_elements_can_be_in_spatial_containers(self):
bpy.ops.bim.create_project()
wall_obj = bpy.data.objects.new("Object", None)
+7
View File
@@ -23,6 +23,11 @@
# ############################################################################ #
# Note: these tests are commented out as they are for learning purposes only. If
# you want to run these tests, uncomment it :)
"""
# Because our tools have well defined, isolated functions, it means we can test
# them very easily in isolation. Tests are fun, fast, and easy to setup!
@@ -85,3 +90,5 @@ class TestShowUserHints(NewFile):
bpy.context.scene.BIMDemoProperties.show_hints = False
subject.show_user_hints()
assert bpy.context.scene.BIMDemoProperties.show_hints == True
"""