Fix failing tests from refactor which I really should've done before the release

This commit is contained in:
Dion Moult
2023-01-09 11:00:46 +11:00
parent 1888048d4d
commit 360b9956c0
6 changed files with 35 additions and 35 deletions
@@ -55,9 +55,7 @@ class Usecase:
ifcopenshell.api.run("spatial.remove_container", model, product=wall)
"""
self.file = file
self.settings = {"product": None}
for key, value in settings.items():
self.settings[key] = value
self.settings = {"product": product}
def execute(self):
contained_in_structure = self.settings["product"].ContainedInStructure
@@ -18,34 +18,7 @@
import ifcopenshell
import ifcopenshell.api
ASSIGNABLE_DICT = {
"IfcZone": ("IfcZone", "IfcSpace", "IfcSpatialZone"),
"IfcBuiltSystem": (
"IfcBuiltElement",
"IfcFurnishingElement",
"IfcElementAssembly",
"IfcTransportElement",
),
"IfcBuildingSystem": (
"IfcBuildingElement",
"IfcFurnishingElement",
"IfcElementAssembly",
"IfcTransportElement",
),
"IfcDistributionSystem": ("IfcDistributionElement",),
"IfcStructuralAnalysisModel": ("IfcStructuralMember", "IfcStructuralConnection"),
"IfcSystem": ("IfcProduct",),
"IfcGroup": ("IfcObjectDefinition",),
}
def is_assignable(product, system) -> bool:
for assignable in ASSIGNABLE_DICT.get(system.is_a(), ()):
if product.is_a(assignable):
return True
return False
import ifcopenshell.util.system
class Usecase:
@@ -82,7 +55,7 @@ class Usecase:
def execute(self):
system = self.settings["system"]
product = self.settings["product"]
if not is_assignable(product, system):
if not ifcopenshell.util.system.is_assignable(product, system):
raise TypeError(f"You cannot assign an {product.is_a()} to an {system.is_a()}")
if not self.settings["system"].IsGroupedBy:
@@ -17,6 +17,34 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
group_types = {
"IfcZone": ("IfcZone", "IfcSpace", "IfcSpatialZone"),
"IfcBuiltSystem": (
"IfcBuiltElement",
"IfcFurnishingElement",
"IfcElementAssembly",
"IfcTransportElement",
),
"IfcBuildingSystem": (
"IfcBuildingElement",
"IfcFurnishingElement",
"IfcElementAssembly",
"IfcTransportElement",
),
"IfcDistributionSystem": ("IfcDistributionElement",),
"IfcStructuralAnalysisModel": ("IfcStructuralMember", "IfcStructuralConnection"),
"IfcSystem": ("IfcProduct",),
"IfcGroup": ("IfcObjectDefinition",),
}
def is_assignable(product, system) -> bool:
for assignable in group_types.get(system.is_a(), ()):
if product.is_a(assignable):
return True
return False
def get_system_elements(system):
results = []
for rel in system.IsGroupedBy: