mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-29 16:22:53 +00:00
When assigning types, your preference of dynamic voids are now preserved.
This commit is contained in:
@@ -77,6 +77,13 @@ def owner():
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def type():
|
||||
prophet = Prophecy(blenderbim.core.tool.Type)
|
||||
yield prophet
|
||||
prophet.verify()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def voider():
|
||||
prophet = Prophecy(blenderbim.core.tool.Voider)
|
||||
|
||||
@@ -179,7 +179,7 @@ class TestAddRepresentation:
|
||||
|
||||
|
||||
class TestSwitchRepresentation:
|
||||
def test_run(self, ifc, geometry, style, surveyor):
|
||||
def test_switching_to_a_freshly_reloaded_representation(self, geometry):
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.import_representation(
|
||||
@@ -199,3 +199,32 @@ class TestSwitchRepresentation:
|
||||
enable_dynamic_voids=True,
|
||||
is_global=True,
|
||||
)
|
||||
|
||||
def test_switching_to_an_existing_representation(self, geometry):
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.change_object_data("obj", "data", is_global=True).should_be_called()
|
||||
geometry.is_body_representation("representation").should_be_called().will_return(True)
|
||||
geometry.create_dynamic_voids("obj").should_be_called()
|
||||
subject.switch_representation(
|
||||
geometry,
|
||||
obj="obj",
|
||||
representation="mapped_rep",
|
||||
should_reload=False,
|
||||
enable_dynamic_voids=True,
|
||||
is_global=True,
|
||||
)
|
||||
|
||||
def test_switching_to_non_dynamic_baked_voids(self, geometry):
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.change_object_data("obj", "data", is_global=False).should_be_called()
|
||||
geometry.clear_dynamic_voids("obj").should_be_called()
|
||||
subject.switch_representation(
|
||||
geometry,
|
||||
obj="obj",
|
||||
representation="mapped_rep",
|
||||
should_reload=False,
|
||||
enable_dynamic_voids=False,
|
||||
is_global=False,
|
||||
)
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# BlenderBIM Add-on - OpenBIM Blender Add-on
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of BlenderBIM Add-on.
|
||||
#
|
||||
# BlenderBIM Add-on is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# BlenderBIM Add-on is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import blenderbim.core.type as subject
|
||||
from test.core.bootstrap import ifc, geometry, type
|
||||
|
||||
|
||||
class TestAssignType:
|
||||
def test_assigning_and_switching_preferably_to_a_body_representation(self, ifc, geometry, type):
|
||||
ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called()
|
||||
type.get_body_representation("element").should_be_called().will_return("mapped_rep")
|
||||
ifc.get_object("element").should_be_called().will_return("obj")
|
||||
type.has_dynamic_voids("obj").should_be_called().will_return(False)
|
||||
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.change_object_data("obj", "data", is_global=False).should_be_called()
|
||||
geometry.clear_dynamic_voids("obj").should_be_called()
|
||||
|
||||
type.disable_editing("obj").should_be_called()
|
||||
|
||||
subject.assign_type(ifc, geometry, type, element="element", type="type")
|
||||
|
||||
def test_assigning_and_switching_to_any_representation_as_a_fallback(self, ifc, geometry, type):
|
||||
ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called()
|
||||
type.get_body_representation("element").should_be_called().will_return(None)
|
||||
type.get_any_representation("element").should_be_called().will_return("mapped_rep")
|
||||
ifc.get_object("element").should_be_called().will_return("obj")
|
||||
type.has_dynamic_voids("obj").should_be_called().will_return(False)
|
||||
|
||||
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
|
||||
geometry.get_representation_data("representation").should_be_called().will_return("data")
|
||||
geometry.change_object_data("obj", "data", is_global=False).should_be_called()
|
||||
geometry.clear_dynamic_voids("obj").should_be_called()
|
||||
|
||||
type.disable_editing("obj").should_be_called()
|
||||
|
||||
subject.assign_type(ifc, geometry, type, element="element", type="type")
|
||||
|
||||
def test_assigning_and_not_changing_representation_if_not_available(self, ifc, type):
|
||||
ifc.run("type.assign_type", related_object="element", relating_type="type").should_be_called()
|
||||
type.get_body_representation("element").should_be_called().will_return(None)
|
||||
type.get_any_representation("element").should_be_called().will_return(None)
|
||||
ifc.get_object("element").should_be_called().will_return("obj")
|
||||
type.disable_editing("obj").should_be_called()
|
||||
subject.assign_type(ifc, geometry, type, element="element", type="type")
|
||||
Reference in New Issue
Block a user