mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
core/tool tests for application methods
This commit is contained in:
@@ -652,6 +652,11 @@ class Owner:
|
||||
def set_person(cls, person): pass
|
||||
def set_role(cls, role): pass
|
||||
def set_user(cls, user): pass
|
||||
def get_application(cls): pass
|
||||
def set_application(cls, application): pass
|
||||
def clear_application(cls): pass
|
||||
def import_application_attributes(cls): pass
|
||||
def export_application_attributes(cls): pass
|
||||
|
||||
|
||||
@interface
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
import bonsai.core.owner as subject
|
||||
from test.core.bootstrap import ifc, owner
|
||||
from test.core.bootstrap import ifc, owner, Prophecy
|
||||
|
||||
|
||||
class TestAddPerson:
|
||||
@@ -271,3 +271,30 @@ class TestUnassignActor:
|
||||
def test_run(self, ifc, owner):
|
||||
ifc.run("owner.unassign_actor", relating_actor="actor", related_object="element").should_be_called()
|
||||
subject.unassign_actor(ifc, actor="actor", element="element")
|
||||
|
||||
|
||||
class TestApplicationUI:
|
||||
def test_enable_editing(self, owner: Prophecy) -> None:
|
||||
owner.set_application("application").should_be_called()
|
||||
owner.import_application_attributes().should_be_called()
|
||||
subject.enable_editing_application(owner, application="application")
|
||||
|
||||
def test_disable_editing(self, owner: Prophecy) -> None:
|
||||
owner.clear_application().should_be_called()
|
||||
subject.disable_editing_application(owner)
|
||||
|
||||
def test_edit(self, ifc: Prophecy, owner: Prophecy) -> None:
|
||||
owner.get_application().should_be_called().will_return("application")
|
||||
owner.export_application_attributes().should_be_called().will_return("attributes")
|
||||
ifc.run("owner.edit_application", application="application", attributes="attributes").should_be_called()
|
||||
owner.clear_application().should_be_called()
|
||||
subject.edit_application(ifc, owner)
|
||||
|
||||
def test_add(self, ifc: Prophecy, owner: Prophecy):
|
||||
ifc.run("owner.add_application").should_be_called().will_return("application")
|
||||
|
||||
# enable editing
|
||||
owner.set_application("application").should_be_called()
|
||||
owner.import_application_attributes().should_be_called()
|
||||
|
||||
assert subject.add_application(ifc, owner) == "application"
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api.owner
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
from test.bim.bootstrap import NewFile
|
||||
@@ -579,3 +580,48 @@ class TestSetUser(NewFile):
|
||||
subject.set_user(user)
|
||||
props = subject.get_owner_props()
|
||||
assert props.active_user_id == user.id()
|
||||
|
||||
|
||||
class TestApplicationUI(NewFile):
|
||||
ifc_class = "IfcApplication"
|
||||
attrs = {
|
||||
"Version": "v001",
|
||||
"ApplicationFullName": "IfcOpenShell",
|
||||
"ApplicationIdentifier": "IfcOpenShell",
|
||||
}
|
||||
|
||||
def test_set(self):
|
||||
application = ifcopenshell.file().create_entity(self.ifc_class)
|
||||
subject.set_application(application)
|
||||
props = subject.get_owner_props()
|
||||
assert props.active_application_id == application.id()
|
||||
|
||||
def test_get(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
application = ifc.create_entity(self.ifc_class)
|
||||
subject.set_application(application)
|
||||
assert subject.get_application() == application
|
||||
|
||||
def test_run_clear(self):
|
||||
application = ifcopenshell.file().create_entity(self.ifc_class)
|
||||
subject.set_application(application)
|
||||
subject.clear_application()
|
||||
props = subject.get_owner_props()
|
||||
assert props.active_application_id == 0
|
||||
|
||||
def test_import(self):
|
||||
ifc = ifcopenshell.file()
|
||||
tool.Ifc.set(ifc)
|
||||
application = ifc.create_entity(self.ifc_class)
|
||||
for attr, value in self.attrs.items():
|
||||
setattr(application, attr, value)
|
||||
subject.set_application(application)
|
||||
subject.import_application_attributes()
|
||||
props = subject.get_owner_props()
|
||||
for attr, value in self.attrs.items():
|
||||
assert props.application_attributes[attr].get_value() == value
|
||||
|
||||
def test_export(self):
|
||||
self.test_import()
|
||||
assert subject.export_application_attributes() == self.attrs
|
||||
|
||||
Reference in New Issue
Block a user