更新审核提示流程与工作台版本
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
12 files changed
+296
-268
No files matched your search
@@ -44,6 +44,53 @@ class QueueTests(unittest.TestCase):
|
||||
return self.store.accept(dict(owner='tab-a', id=job['id'], post_url='https://www.dww11.com/thread/12345.html',
|
||||
thread_id='123', first_post_pid='456', author_uid='123', fid=125, title=job['title'], state='accepted_pending_moderation', evidence={'thread_id': '123', 'test': 'fixture only'}))
|
||||
|
||||
def prompt_data(self, job):
|
||||
current = self.store.state()['jobs'][0]
|
||||
message = '新主题需要审核,您的帖子通过审核后才能显示'
|
||||
return dict(owner='tab-a', id=job['id'], attempt=current.get('attempt'),
|
||||
state='accepted_pending_moderation', evidence=dict(adapter='moderation_prompt',
|
||||
message=message, observed_text=message + ',现在将转入首页',
|
||||
observed_url='https://www.dww11.com/forum.php?topicsubmit=yes'))
|
||||
|
||||
def test_prompt_accept_counts_once_and_persists_dedup(self):
|
||||
job = self.begin()
|
||||
self.submit(job)
|
||||
data = self.prompt_data(job)
|
||||
self.store.accept(data)
|
||||
self.assertTrue(self.store.accept(data)['duplicate'])
|
||||
state = self.store.state()
|
||||
self.assertEqual(state['run']['batch']['count'], 1)
|
||||
self.assertIsNone(state['run']['active'])
|
||||
self.assertTrue(state['run']['return_home'])
|
||||
self.assertTrue(state['run']['running'])
|
||||
saved = state['jobs'][0]
|
||||
self.assertEqual(saved['state'], 'accepted_pending_moderation')
|
||||
self.assertEqual(saved.get('post_url'), '')
|
||||
self.assertNotIn('thread_id', saved)
|
||||
restarted = Store(self.root / 'queue.sqlite3')
|
||||
self.assertIn('已受理', restarted.enqueue(self.article))
|
||||
|
||||
def test_prompt_requires_manual_submission_and_current_attempt(self):
|
||||
job = self.begin()
|
||||
with self.assertRaisesRegex(ValueError, '人工提交'):
|
||||
self.store.accept(self.prompt_data(job))
|
||||
self.submit(job)
|
||||
data = self.prompt_data(job)
|
||||
for changed in ({'attempt': 'old'}, {'evidence': {**data['evidence'], 'observed_text': '(审核中)'}},
|
||||
{'evidence': {**data['evidence'], 'observed_url': 'https://example.com/'}}):
|
||||
with self.assertRaises(ValueError):
|
||||
self.store.accept({**data, **changed})
|
||||
self.assertEqual(self.store.run['batch']['count'], 0)
|
||||
|
||||
def test_prompt_after_stop_records_without_resuming(self):
|
||||
job = self.begin()
|
||||
self.submit(job)
|
||||
data = self.prompt_data(job)
|
||||
self.store.control('stop')
|
||||
self.store.accept(data)
|
||||
self.assertFalse(self.store.run['running'])
|
||||
self.assertEqual(self.store.run['batch']['count'], 1)
|
||||
|
||||
def test_stable_identity_and_original_preserved(self):
|
||||
before = self.md.read_bytes()
|
||||
item = inspect_article(self.article)
|
||||
|
||||
Reference in new issue
Block a user