Fix ci-bonsai-daily BDD: OperatorSpy.bl_rna + stale MEP port name

Two independent test-harness/fixture defects in test/bim/test_feature.py:

- OperatorSpy had no bl_rna, so any BDD step that redraws a panel calling
  helper.draw_filter() (which tests "module" in op.bl_rna.properties)
  crashed with AttributeError. Give OperatorSpy a bl_rna property that
  forwards to the real registered operator class
  (bpy.types[bl_idname].bl_rna), matching live UILayout.operator()
  semantics. Fixes test_select_all_walls and test_edit_filter_query.
- The shared "I create default MEP types" step looked up
  bpy.data.objects["IfcDistributionPort/Port"], but port creation never
  sets port.Name, so tool.Loader.get_name deterministically names the
  object "IfcDistributionPort/Unnamed". Update the literal. Fixes the MEP
  scenarios (connect/transition/bend) that share this setup.

Verified in headless Blender: OperatorSpy scenarios 2 passed (were
AttributeError); MEP test_connect_mep_elements* go from
KeyError 'IfcDistributionPort/Port' to passing.

This change was made with the assistance of an AI tool.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Petru Conduraru
2026-07-12 22:50:08 +03:00
committed by Dion Moult
parent 836d57e7ff
commit e27624c77f
+21 -2
View File
@@ -187,7 +187,14 @@ class PanelSpy:
after = ""
if self.spied_labels:
after = self.spied_labels[-1]
spied_operator = {"operator": operator, "icon": icon, "text": text, "kwargs": {}, "after": after}
spied_operator = {
"operator": operator,
"icon": icon,
"text": text,
"kwargs": {},
"after": after,
"bl_idname": bl_idname,
}
self.spied_operators.append(spied_operator)
return OperatorSpy(spied_operator)
elif self.spied_attr == "panel":
@@ -210,6 +217,14 @@ class OperatorSpy:
else:
self.spied_data["kwargs"][name] = value
@property
def bl_rna(self) -> Any:
# Mirror the real `UILayout.operator()` return value (an OperatorProperties
# instance), which exposes `.bl_rna` so panel code such as
# `"module" in op.bl_rna.properties` (bonsai/bim/helper.py) also works when
# drawing is spied on during BDD tests.
return getattr(bpy.types, self.spied_data["bl_idname"]).bl_rna
class TemplateListSpy(PanelSpy):
items: bpy.types.bpy_prop_collection_idprop[bpy.types.PropertyGroup]
@@ -773,7 +788,11 @@ def i_create_default_mep_types():
with bpy.context.temp_override(active_object=bpy.data.objects["IfcActuatorType/ACTUATOR"]):
bpy.ops.bim.add_port()
# port at cube's left side
bpy.data.objects["IfcDistributionPort/Port"].location = (-0.5, 0, 0)
# Newly created ports are never given an explicit IFC `.Name` (see
# `core/system.py:create_port_at_cursor` / `tool/system.py`), so
# `tool.Loader.get_name()` falls back to the standard "Unnamed" convention
# used throughout Bonsai for freshly-created, not-yet-named elements.
bpy.data.objects["IfcDistributionPort/Unnamed"].location = (-0.5, 0, 0)
bpy.ops.bim.hide_ports()