2024-08-13 15:47:27 +10:00
|
|
|
# Bonsai - OpenBIM Blender Add-on
|
2021-10-07 18:51:50 +11:00
|
|
|
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
|
|
|
|
#
|
2024-08-13 15:47:27 +10:00
|
|
|
# This file is part of Bonsai.
|
2021-10-07 18:51:50 +11:00
|
|
|
#
|
2024-08-13 15:47:27 +10:00
|
|
|
# Bonsai is free software: you can redistribute it and/or modify
|
2021-10-07 18:51:50 +11:00
|
|
|
# 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.
|
|
|
|
|
#
|
2024-08-13 15:47:27 +10:00
|
|
|
# Bonsai is distributed in the hope that it will be useful,
|
2021-10-07 18:51:50 +11:00
|
|
|
# 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
|
2024-08-13 15:47:27 +10:00
|
|
|
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
|
2021-10-07 18:51:50 +11:00
|
|
|
|
2024-08-14 15:41:52 +05:00
|
|
|
import bonsai.core.aggregate as subject
|
2026-01-26 17:11:12 +05:00
|
|
|
from test.core.bootstrap import aggregate, collector, ifc
|
2021-10-06 12:50:46 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestEnableEditingAggregate:
|
2021-10-07 18:51:50 +11:00
|
|
|
def test_run(self, aggregate):
|
|
|
|
|
aggregate.enable_editing("obj").should_be_called()
|
|
|
|
|
subject.enable_editing_aggregate(aggregate, obj="obj")
|
2021-10-06 12:50:46 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestDisableEditingAggregate:
|
2021-10-07 18:51:50 +11:00
|
|
|
def test_run(self, aggregate):
|
|
|
|
|
aggregate.disable_editing("obj").should_be_called()
|
|
|
|
|
subject.disable_editing_aggregate(aggregate, obj="obj")
|
2021-10-06 12:50:46 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestAssignObject:
|
2021-10-07 18:51:50 +11:00
|
|
|
def test_run(self, ifc, aggregate, collector):
|
|
|
|
|
aggregate.can_aggregate("relating_obj", "related_obj").should_be_called().will_return(True)
|
2021-10-06 12:50:46 +11:00
|
|
|
ifc.get_entity("relating_obj").should_be_called().will_return("relating_object")
|
2024-08-01 16:55:43 +05:00
|
|
|
aggregate.has_physical_body_representation("relating_object").should_be_called().will_return(False)
|
2021-10-06 12:50:46 +11:00
|
|
|
ifc.get_entity("related_obj").should_be_called().will_return("related_object")
|
|
|
|
|
ifc.run(
|
2024-04-08 16:23:48 +05:00
|
|
|
"aggregate.assign_object", products=["related_object"], relating_object="relating_object"
|
2021-10-06 12:50:46 +11:00
|
|
|
).should_be_called().will_return("rel")
|
2021-10-07 18:51:50 +11:00
|
|
|
aggregate.disable_editing("related_obj").should_be_called()
|
2021-10-06 12:50:46 +11:00
|
|
|
collector.assign("relating_obj").should_be_called()
|
|
|
|
|
collector.assign("related_obj").should_be_called()
|
|
|
|
|
assert (
|
2021-10-07 18:51:50 +11:00
|
|
|
subject.assign_object(ifc, aggregate, collector, relating_obj="relating_obj", related_obj="related_obj")
|
2021-10-06 12:50:46 +11:00
|
|
|
== "rel"
|
|
|
|
|
)
|
2021-10-06 14:11:54 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestUnassignObject:
|
2023-03-11 16:31:09 +11:00
|
|
|
def test_run(self, ifc, aggregate, collector):
|
|
|
|
|
ifc.get_entity("related_obj").should_be_called().will_return("element")
|
|
|
|
|
aggregate.get_container("element").should_be_called().will_return("container")
|
2024-04-05 14:57:11 +05:00
|
|
|
ifc.run("spatial.assign_container", products=["element"], relating_structure="container").should_be_called()
|
2024-04-08 17:38:41 +05:00
|
|
|
ifc.run("aggregate.unassign_object", products=["element"]).should_be_called()
|
2021-10-06 14:11:54 +11:00
|
|
|
collector.assign("relating_obj").should_be_called()
|
|
|
|
|
collector.assign("related_obj").should_be_called()
|
2023-03-11 16:31:09 +11:00
|
|
|
subject.unassign_object(ifc, aggregate, collector, relating_obj="relating_obj", related_obj="related_obj")
|