修复新闻工作台换号联动流程
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
15 files changed
+203
-34
No files matched your search
+29
-1
@@ -22,7 +22,7 @@ class QueueTests(unittest.TestCase):
|
||||
self.md.write_text('# 测试新闻\n\n正文内容。\n\n来源:测试来源,如有侵权,请联系删除。\n')
|
||||
self.store = Store(self.root / 'queue.sqlite3')
|
||||
self.store.configure(dict(fid=125, minimum=1, maximum=1, interval=0, history_checked=True))
|
||||
self.owner = dict(owner='tab-a', account=dict(uid='123', name='测试账号'), extension={'idle': True}, url='https://www.dww11.com/')
|
||||
self.owner = dict(owner='tab-a', account=dict(uid='123', name='测试账号'), extension={'ready': True, 'idle': True}, url='https://www.dww11.com/')
|
||||
|
||||
def tearDown(self):
|
||||
self.tmp.cleanup()
|
||||
@@ -321,6 +321,34 @@ class QueueTests(unittest.TestCase):
|
||||
self.assertFalse(self.store.run['running'])
|
||||
self.assertEqual(self.store.run['switch']['state'], 'clicked')
|
||||
|
||||
def pending_switch(self):
|
||||
import time
|
||||
job = self.begin(); self.submit(job); self.accept(job)
|
||||
other = self.root / 'other'; shutil.copytree(self.article, other)
|
||||
(other / 'a.md').write_text(self.md.read_text().replace('正文内容', '另一篇内容'))
|
||||
self.store.enqueue(other)
|
||||
self.assertEqual(self.store.next(self.owner)['action'], 'switch')
|
||||
self.store.run['switch']['created_at'] = time.time() - 3600
|
||||
|
||||
def test_old_pending_switch_does_not_timeout_before_click(self):
|
||||
self.pending_switch()
|
||||
self.store.control('pause'); self.store.control('start')
|
||||
self.assertEqual(self.store.next(self.owner)['action'], 'switch')
|
||||
self.assertTrue(self.store.run['running'])
|
||||
self.assertNotIn('clicked_at', self.store.run['switch'])
|
||||
|
||||
def test_missing_bridge_explains_problem_and_preserves_pending_switch(self):
|
||||
self.pending_switch()
|
||||
changed = {**self.owner, 'account': {'uid': '456', 'name': '手动换号后的账号'}, 'extension': {}}
|
||||
self.assertEqual(self.store.next(changed)['action'], 'idle')
|
||||
self.assertIn('联动接口未就绪', self.store.run['reason'])
|
||||
self.assertEqual(self.store.run['switch']['state'], 'pending')
|
||||
self.assertEqual(self.store.run['batch']['count'], 1)
|
||||
self.store.control('start')
|
||||
self.assertEqual(self.store.next({**changed, 'extension': {'ready': True, 'idle': True}})['action'], 'prepare')
|
||||
self.assertIsNone(self.store.run['switch'])
|
||||
self.assertEqual(self.store.run['batch']['count'], 0)
|
||||
|
||||
def test_rejected_submission_requires_manual_resolution(self):
|
||||
job = self.begin(); self.submit(job)
|
||||
self.transition(job, 'rejected', error='标题超限')
|
||||
|
||||
Reference in new issue
Block a user