43 lines
2.0 KiB
Python
43 lines
2.0 KiB
Python
"""Isolated synthetic review fixture. No production records or model calls."""
|
|
from pathlib import Path
|
|
import sys, threading, time, json
|
|
sys.path.insert(0, 'C:/wechat_rpa')
|
|
import admin_backend, admin_api
|
|
from archive_store import ArchiveStore
|
|
from knowledge_store import KnowledgeStore
|
|
from knowledge_review import KnowledgeReviewWorker
|
|
from test_knowledge_review import FullReviewTest
|
|
|
|
folder = Path(__file__).resolve().parent
|
|
db = admin_backend.Database(folder/'backend.db')
|
|
if not db.path.exists():
|
|
db.initialize('InitialAdmin123')
|
|
actor = db.authenticate('admin', 'InitialAdmin123')['id']
|
|
db.change_password(actor, 'InitialAdmin123', 'KnowledgeQA@2026', '')
|
|
store = KnowledgeStore(db); store.initialize()
|
|
fixture = FullReviewTest()
|
|
fixture.db = db; fixture.store = store; fixture.actor = actor; fixture.archive = ArchiveStore(db)
|
|
accounts = []
|
|
for index, count in enumerate([37, 40]):
|
|
_, account = db.create_desktop_session({'user_id':f'full-review-qa-{index}', 'sn':f'QA00{index+1}',
|
|
'nickname':['全量验收客服甲','全量验收客服乙'][index]}, f'qa-device-{index}', 'QA', '1.0', '127.0.0.1')
|
|
ids = fixture.seed(count, account['tenant_id'])
|
|
if index == 0:
|
|
with db.connect() as connection:
|
|
connection.execute("UPDATE knowledge_item SET conditions='' WHERE id=?", (ids[0],))
|
|
connection.execute("UPDATE knowledge_item SET valid_until='2000-01-01' WHERE id=?", (ids[1],))
|
|
accounts.append({'id':account['id'], 'tenant_id':account['tenant_id'], 'count':count})
|
|
(folder/'fixture.json').write_text(json.dumps(accounts), encoding='utf-8')
|
|
|
|
app = admin_api.create_app(db.path)
|
|
def work():
|
|
worker = KnowledgeReviewWorker(app.state.knowledge_store)
|
|
while True:
|
|
worker.step(10)
|
|
time.sleep(0.4)
|
|
|
|
if __name__ == '__main__':
|
|
import uvicorn
|
|
threading.Thread(target=work, daemon=True).start()
|
|
uvicorn.run(app, host='127.0.0.1', port=18872, log_level='warning')
|