fix: close batch execution and recovery lifecycle

This commit is contained in:
阿白叔 committed 2026-11-17 16:56:29 +08:00
1 parent b19afc6a53
commit d9cf6a07e9
91 files changed
+5779 -454

No files matched your search

@@ -1,18 +1,14 @@
import importlib.util
import inspect
from pathlib import Path
import subprocess
import tempfile
from types import SimpleNamespace
import unittest
from unittest.mock import call, patch
ROOT = Path(__file__).resolve().parents[2]
RUNTIME = ROOT / "integration" / "dxdesigner795"
SPEC = importlib.util.spec_from_file_location(
"native", ROOT / "src" / "dx_productivity" / "trial_task_center" / "native_helper.py"
)
native = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(native)
from dx_productivity.trial_task_center import native_helper as native
FAKES = r"""
Class TestPoint
@@ -107,7 +103,7 @@ End Sub
class NativeTests(unittest.TestCase):
def test_native_command_does_not_use_physical_mouse_fallback(self):
source = inspect.getsource(native.run_native)
source = inspect.getsource(inspect.unwrap(native.run_native))
self.assertIn("replacement_command_from_resources(executable)", source)
self.assertNotIn("win32api.SetCursorPos", source)
@@ -115,20 +111,24 @@ class NativeTests(unittest.TestCase):
self.assertNotIn("win32gui.SetCursorPos(screen_point)", source)
def test_snapshot_batch_is_reselected_before_the_strict_selection_gate(self):
app = object()
api = object()
metadata = ["M"]
first = type("Component", (), {"UID": "wanted"})()
other = type("Component", (), {"UID": "other"})()
first = SimpleNamespace(UID='wanted', Refdes='R1', Selected=False)
other = SimpleNamespace(UID='other', Refdes='R2', Selected=True)
first._oleobj_, other._oleobj_ = first, other
app = SimpleNamespace(ActiveView=SimpleNamespace(Query=lambda kind, scope:
[component for component in (first, other) if component.Selected]))
api = SimpleNamespace(IVdComp=lambda value:value)
records = [["C", "wanted"]]
with patch.object(native, "check_context", side_effect=([first, other], [first, other])) as check:
with patch.object(native, "selection") as select:
with patch.object(native, "check_context", return_value=[first, other]) as check:
with patch.object(native, "selection", side_effect=lambda component, selected:setattr(component,'Selected',selected)) as select, \
patch.object(native, "check_active_context"):
result = native.select_snapshot_batch(app, api, metadata, records)
self.assertEqual(result, [first, other])
self.assertEqual(check.call_args_list[0], call(app, api, metadata, records, require_selection=False))
self.assertEqual(check.call_args_list[1], call(app, api, metadata, records))
self.assertEqual(select.call_args_list, [call(first, True), call(other, False)])
self.assertTrue(first.Selected)
self.assertFalse(other.Selected)
def test_snapshot_escape_format(self):
self.assertEqual(native.decode("a%0009b%000Ac%0025"), "a\tb\nc%")