Files
IfcOpenShell/src/bonsai/test/tool/test_pset.py
T

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

55 lines
1.9 KiB
Python
Raw Normal View History

2024-08-13 15:47:27 +10:00
# Bonsai - OpenBIM Blender Add-on
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
#
2024-08-13 15:47:27 +10:00
# This file is part of Bonsai.
#
2024-08-13 15:47:27 +10:00
# Bonsai 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.
#
2024-08-13 15:47:27 +10:00
# Bonsai 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
2024-08-13 15:47:27 +10:00
# along with Bonsai. If not, see <http://www.gnu.org/licenses/>.
import bpy
import ifcopenshell
2025-06-09 10:59:22 +05:00
import ifcopenshell.api
import ifcopenshell.api.pset
2026-01-26 17:11:12 +05:00
2024-08-14 13:56:39 +05:00
import bonsai.core.tool
import bonsai.tool as tool
from bonsai.tool.pset import Pset as subject
from test.bim.bootstrap import NewFile
class TestImplementsTool(NewFile):
def test_run(self):
2024-08-14 13:56:39 +05:00
assert isinstance(subject(), bonsai.core.tool.Pset)
class TestGetElementPset(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
element = ifc.createIfcWall()
2025-06-09 10:59:22 +05:00
pset = ifcopenshell.api.pset.add_pset(ifc, product=element, name="Foo")
assert subject.get_element_pset(element, "Foo") == pset
class TestIsPsetEmpty(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
element = ifc.createIfcWall()
2025-06-09 10:59:22 +05:00
pset = ifcopenshell.api.pset.add_pset(ifc, product=element, name="Foo")
assert subject.is_pset_empty(pset) is True
2025-06-09 10:59:22 +05:00
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"Foo": "Bar"})
assert subject.is_pset_empty(pset) is False
2025-06-09 10:59:22 +05:00
ifcopenshell.api.pset.edit_pset(ifc, pset=pset, properties={"Foo": None})
assert subject.is_pset_empty(pset) is True