Files
IfcOpenShell/src/ifcopenshell-python/test/api/test_api.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
2.1 KiB
Python
Raw Normal View History

# IfcOpenShell - IFC toolkit and geometry engine
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
# This file is part of IfcOpenShell.
#
# IfcOpenShell is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# IfcOpenShell 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 Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
2025-12-19 18:53:04 +05:00
from datetime import datetime
2025-09-09 11:14:57 +05:00
import ifcopenshell.api.control
2025-12-19 18:53:04 +05:00
import ifcopenshell.api.cost
import ifcopenshell.api.root
2025-09-09 11:14:57 +05:00
import ifcopenshell.util.element
2025-12-19 18:53:04 +05:00
import test.bootstrap
def deprecation_check(test):
def new_test(self):
2025-09-09 11:14:57 +05:00
assert datetime.now().date() < datetime(2026, 1, 9).date(), "API arguments are completely deprecated"
test(self)
return new_test
class TestTemporarySupportForDeprecatedAPIArguments(test.bootstrap.IFC4):
2025-09-09 11:14:57 +05:00
@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)) == []