mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 22:22:26 +00:00
control.assign_control - remove deprecated related_object argument support
This commit is contained in:
@@ -42,7 +42,6 @@ import importlib
|
|||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from functools import partial
|
|
||||||
from typing import TYPE_CHECKING, Any, Optional
|
from typing import TYPE_CHECKING, Any, Optional
|
||||||
|
|
||||||
import numpy
|
import numpy
|
||||||
@@ -90,11 +89,7 @@ def renamed_arguments_deprecation(
|
|||||||
# "group.add_group": partial(
|
# "group.add_group": partial(
|
||||||
# renamed_arguments_deprecation, arguments_remapped={"Name": "name", "Description": "description"}
|
# renamed_arguments_deprecation, arguments_remapped={"Name": "name", "Description": "description"}
|
||||||
# ),
|
# ),
|
||||||
ARGUMENTS_DEPRECATION: dict[str, Callable[[str, dict[str, Any]], tuple[str, dict[str, Any]]]] = {
|
ARGUMENTS_DEPRECATION: dict[str, Callable[[str, dict[str, Any]], tuple[str, dict[str, Any]]]] = {}
|
||||||
"control.assign_control": partial(
|
|
||||||
batching_argument_deprecation, prev_argument="related_object", new_argument="related_objects"
|
|
||||||
),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
CACHED_USECASE_CLASSES: dict[str, Callable] = {}
|
CACHED_USECASE_CLASSES: dict[str, Callable] = {}
|
||||||
|
|||||||
@@ -15,38 +15,3 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
import ifcopenshell.api.control
|
|
||||||
import ifcopenshell.api.cost
|
|
||||||
import ifcopenshell.api.root
|
|
||||||
import ifcopenshell.util.element
|
|
||||||
import test.bootstrap
|
|
||||||
|
|
||||||
|
|
||||||
def deprecation_check(test):
|
|
||||||
def new_test(self):
|
|
||||||
assert datetime.now().date() < datetime(2026, 1, 9).date(), "API arguments are completely deprecated"
|
|
||||||
test(self)
|
|
||||||
|
|
||||||
return new_test
|
|
||||||
|
|
||||||
|
|
||||||
class TestTemporarySupportForDeprecatedAPIArguments(test.bootstrap.IFC4):
|
|
||||||
@deprecation_check
|
|
||||||
def test_assigning_control(self):
|
|
||||||
model = self.file
|
|
||||||
element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
|
|
||||||
control = ifcopenshell.api.cost.add_cost_schedule(model)
|
|
||||||
ifcopenshell.api.control.assign_control(model, relating_control=control, related_objects=[element])
|
|
||||||
assert list(ifcopenshell.util.element.get_controls(element)) == [control]
|
|
||||||
|
|
||||||
@deprecation_check
|
|
||||||
def test_unassigning_control(self):
|
|
||||||
TestTemporarySupportForDeprecatedAPIArguments.test_assigning_control(self)
|
|
||||||
model = self.file
|
|
||||||
element = model.by_type("IfcWall")[0]
|
|
||||||
control = model.by_type("IfcCostSchedule")[0]
|
|
||||||
ifcopenshell.api.control.unassign_control(model, relating_control=control, related_objects=[element])
|
|
||||||
assert list(ifcopenshell.util.element.get_controls(element)) == []
|
|
||||||
|
|||||||
Reference in New Issue
Block a user