Host operator: drop the redundant _wrote writes; tests pin the envelope and the own add-on never read as a host
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c1aacd9f7b
commit
26efb1b31a
2 changed files with 11 additions and 4 deletions
|
|
@ -847,11 +847,9 @@ class BrokkrBlenderTarget:
|
|||
text = getattr(manager, result, "") or ""
|
||||
if len(text) > HOST_RESULT_LIMIT:
|
||||
text = text[:HOST_RESULT_LIMIT] + " [truncated]"
|
||||
if "FINISHED" in outcome:
|
||||
self._wrote = bool(row["changesScene"])
|
||||
if "FINISHED" in outcome: # run_intent pushes an undo step for an accepted changesScene row only
|
||||
receipt = self._receipt(command, "accepted", f"Operator {name} finished.", "")
|
||||
else:
|
||||
self._wrote = False
|
||||
receipt = self._receipt(command, "failed", f"Operator {name} cancelled; nothing changed.", "")
|
||||
receipt["hostResult"] = text
|
||||
return receipt
|
||||
|
|
|
|||
|
|
@ -326,9 +326,14 @@ class HostActionTests(unittest.TestCase):
|
|||
def test_the_default_is_filled_and_an_undeclared_field_never_reaches_the_operator(self):
|
||||
self.assertEqual(self.send("add_empty", name="E")["status"], "accepted")
|
||||
self.assertEqual(self.ops["add_empty"].calls, [{"name": "E", "size": 1}])
|
||||
self.ops["add_empty"].calls.clear()
|
||||
self.assertEqual(self.send("add_empty", name="E", note="why")["status"], "accepted")
|
||||
self.assertEqual(self.ops["add_empty"].calls, [{"name": "E", "size": 1}]) # the envelope never reaches the operator
|
||||
self.ops["add_empty"].calls.clear()
|
||||
self.ops["add_empty"].calls.append({})
|
||||
denied = self.send("add_empty", name="E", location=[1, 2, 3])
|
||||
self.assertEqual(denied["status"], "denied")
|
||||
self.assertEqual(len(self.ops["add_empty"].calls), 1)
|
||||
self.assertEqual(len(self.ops["add_empty"].calls), 1) # only the seeded marker: the denied intent ran nothing
|
||||
|
||||
def test_a_non_changing_operator_pushes_no_undo_step_and_returns_its_result(self):
|
||||
receipt = self.send("report")
|
||||
|
|
@ -452,6 +457,10 @@ class HostActionTests(unittest.TestCase):
|
|||
self.assertEqual(self.target.host_actions(), ([], []))
|
||||
self.bpy.context.preferences.addons["brokkr_bridge"] = object()
|
||||
self.assertEqual(self.target.host_actions(), ([], []))
|
||||
(self.dir / "brokkr_actions.json").write_bytes((FIXTURE / "brokkr_actions.json").read_bytes())
|
||||
with unittest.mock.patch.object(sys.modules["brokkr_bridge"], "__file__", str(self.dir / "__init__.py"), create=True):
|
||||
self.bpy.context.preferences.addons.pop(HOST) # a file sits beside this add-on itself: still not read as a host's
|
||||
self.assertEqual(self.target.host_actions(), ([], []))
|
||||
|
||||
|
||||
class FakeNode:
|
||||
|
|
|
|||
Loading…
Reference in a new issue