mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-11 06:18:09 +00:00
Unlinking elements is now a bit more stable. Also simplify core tool namespace.
This commit is contained in:
@@ -77,6 +77,20 @@ def owner():
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def voider():
|
||||
prophet = Prophecy(blenderbim.core.tool.Voider)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def selector():
|
||||
prophet = Prophecy(blenderbim.core.tool.Selector)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def surveyor():
|
||||
prophet = Prophecy(blenderbim.core.tool.Surveyor)
|
||||
@@ -84,6 +98,20 @@ def surveyor():
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def collector():
|
||||
prophet = Prophecy(blenderbim.core.tool.Collector)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def container():
|
||||
prophet = Prophecy(blenderbim.core.tool.Container)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
class Prophecy:
|
||||
def __init__(self, cls):
|
||||
self.subject = cls
|
||||
|
||||
@@ -26,7 +26,7 @@ from blenderbim.tool.context_editor import ContextEditor as subject
|
||||
|
||||
class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
assert isinstance(subject(), blenderbim.core.tool.context_editor.ContextEditor)
|
||||
assert isinstance(subject(), blenderbim.core.tool.ContextEditor)
|
||||
|
||||
|
||||
class TestSetContext(test.bim.bootstrap.NewFile):
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import test.bim.bootstrap
|
||||
import blenderbim.core.tool.ifc
|
||||
from blenderbim.tool import Ifc as subject
|
||||
import blenderbim.core.tool
|
||||
from blenderbim.tool.ifc import Ifc as subject
|
||||
|
||||
|
||||
class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
assert isinstance(subject(), blenderbim.core.tool.ifc.Ifc)
|
||||
assert isinstance(subject(), blenderbim.core.tool.Ifc)
|
||||
|
||||
|
||||
class TestSet(test.bim.bootstrap.NewFile):
|
||||
@@ -64,7 +64,7 @@ class TestGetSchema(test.bim.bootstrap.NewFile):
|
||||
assert subject.get_schema() == "IFC4"
|
||||
|
||||
|
||||
class TestGetElement(test.bim.bootstrap.NewFile):
|
||||
class TestGetEntity(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
@@ -88,3 +88,56 @@ class TestGetElement(test.bim.bootstrap.NewFile):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMObjectProperties.ifc_definition_id = 1
|
||||
assert subject.get_entity(obj) is None
|
||||
|
||||
|
||||
class TestGetObject(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
subject.link(element, obj)
|
||||
assert subject.get_object(element) == obj
|
||||
|
||||
|
||||
class TestLink(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
subject.link(element, obj)
|
||||
assert subject.get_entity(obj) == element
|
||||
assert subject.get_object(element) == obj
|
||||
|
||||
|
||||
class TestUnlink(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
subject.link(element, obj)
|
||||
subject.unlink(element, obj)
|
||||
assert subject.get_entity(obj) is None
|
||||
assert subject.get_object(element) is None
|
||||
|
||||
def test_unlinking_using_an_object(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
subject.link(element, obj)
|
||||
subject.unlink(obj=obj)
|
||||
assert subject.get_entity(obj) is None
|
||||
assert subject.get_object(element) is None
|
||||
|
||||
def test_unlinking_using_an_element(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
element = ifc.createIfcWall()
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
subject.link(element, obj)
|
||||
subject.unlink(element=element)
|
||||
assert subject.get_entity(obj) is None
|
||||
assert subject.get_object(element) is None
|
||||
|
||||
@@ -26,7 +26,7 @@ from blenderbim.tool.organisation_editor import OrganisationEditor as subject
|
||||
|
||||
class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
assert isinstance(subject(), blenderbim.core.tool.organisation_editor.OrganisationEditor)
|
||||
assert isinstance(subject(), blenderbim.core.tool.OrganisationEditor)
|
||||
|
||||
|
||||
class TestSetOrganisation(test.bim.bootstrap.NewFile):
|
||||
|
||||
@@ -8,7 +8,7 @@ from blenderbim.tool.owner import Owner as subject
|
||||
|
||||
class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
assert isinstance(subject(), blenderbim.core.tool.owner.Owner)
|
||||
assert isinstance(subject(), blenderbim.core.tool.Owner)
|
||||
|
||||
|
||||
class TestSetUser(test.bim.bootstrap.NewFile):
|
||||
|
||||
@@ -26,7 +26,7 @@ from blenderbim.tool.person_editor import PersonEditor as subject
|
||||
|
||||
class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
assert isinstance(subject(), blenderbim.core.tool.person_editor.PersonEditor)
|
||||
assert isinstance(subject(), blenderbim.core.tool.PersonEditor)
|
||||
|
||||
|
||||
class TestSetPerson(test.bim.bootstrap.NewFile):
|
||||
|
||||
@@ -26,7 +26,7 @@ from blenderbim.tool.role_editor import RoleEditor as subject
|
||||
|
||||
class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
assert isinstance(subject(), blenderbim.core.tool.role_editor.RoleEditor)
|
||||
assert isinstance(subject(), blenderbim.core.tool.RoleEditor)
|
||||
|
||||
|
||||
class TestSetRole(test.bim.bootstrap.NewFile):
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import bpy
|
||||
import numpy as np
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import blenderbim.tool as tool
|
||||
|
||||
import test.bim.bootstrap
|
||||
import blenderbim.core.tool.surveyor
|
||||
import numpy as np
|
||||
import blenderbim.core.tool
|
||||
import blenderbim.tool as tool
|
||||
from blenderbim.tool import Surveyor as subject
|
||||
|
||||
|
||||
class TestImplementsTool(test.bim.bootstrap.NewFile):
|
||||
def test_run(self):
|
||||
assert isinstance(subject(), blenderbim.core.tool.surveyor.Surveyor)
|
||||
assert isinstance(subject(), blenderbim.core.tool.Surveyor)
|
||||
|
||||
|
||||
class TestGetGlobalMatrix(test.bim.bootstrap.NewFile):
|
||||
|
||||
Reference in New Issue
Block a user