46 lines
2.1 KiB
Python
46 lines
2.1 KiB
Python
from pathlib import Path
|
|
import os
|
|
import shutil
|
|
|
|
for root in (Path(r'C:\kefu\wechat_rpa'), Path(r'C:\wechat_rpa')):
|
|
backup = root / 'backups/review-visibility-20260916/qt'
|
|
for name in ('test_queue_log.py', 'test_qt_console_bridge.py'):
|
|
path = root / name
|
|
if not (backup / name).exists():
|
|
shutil.copy2(path, backup / name)
|
|
text = path.read_text(encoding='utf-8')
|
|
if name == 'test_queue_log.py':
|
|
old = 'self.page._state_text({"send_state": "uncertain"}), "发送待核对"'
|
|
assert old in text
|
|
text = text.replace(old, 'self.page._state_text({"send_state": "uncertain"}), "发送待核对(需人工)"')
|
|
else:
|
|
start = text.index(' def test_handoff_only_reports_tasks_the_backend_accepted(self):')
|
|
end = text.index(' def test_queue_actions_select_exact_key_before_forwarding', start)
|
|
text = text[:start] + ''' def test_handoff_only_reports_tasks_the_backend_accepted(self):
|
|
thread = SimpleNamespace(
|
|
is_alive=lambda: True,
|
|
handoff_pending_tasks=mock.Mock(return_value={
|
|
"handed_off": ["done"], "scheduled": [],
|
|
"protected": ["protected"], "error": "",
|
|
}),
|
|
)
|
|
host = SimpleNamespace(
|
|
_thread=thread,
|
|
queue_page=SimpleNamespace(pending_states={}, refresh_data=mock.Mock()),
|
|
append_log=mock.Mock(), _schedule_console_push=mock.Mock(),
|
|
)
|
|
with mock.patch("wechat_gui_qt.QMessageBox.information") as notice:
|
|
MainWindow._handoff_queue_tasks(host, ["done", "protected"])
|
|
thread.handoff_pending_tasks.assert_called_once_with(["done", "protected"])
|
|
host.append_log.assert_called_once_with(
|
|
"已将 1 条任务转交人工,保留发送记录,不再自动重发。", "notify",
|
|
)
|
|
notice.assert_called_once()
|
|
host.queue_page.refresh_data.assert_called_once_with()
|
|
|
|
''' + text[end:]
|
|
temp = path.with_suffix('.audit-tmp')
|
|
temp.write_text(text, encoding='utf-8')
|
|
os.replace(temp, path)
|
|
print(str(root) + ': updated regression contracts')
|