Files

14 lines
1.7 KiB
Python

import pathlib,urllib.request,hashlib,json,sqlite3
b=pathlib.Path('/www/dk_project/dk_app/trilium');s=pathlib.Path('/tmp/trilium-api-final');h=lambda p:hashlib.sha256(p.read_bytes()).hexdigest()
assert h(b/'patched/main.cjs')==h(s/'main.cjs')
for rel in ['etapi.json','internal.json','frontend.html','fnote.html','backend.html','swagger/swagger-ui-bundle.js','swagger/swagger-ui-standalone-preset.js','swagger/swagger-ui.css']:
with urllib.request.urlopen('http://127.0.0.1:18082/assets/v0.95.0-ko-20260913-r8/doc_notes/en/api-ko/'+rel,timeout=5) as r:assert hashlib.sha256(r.read()).hexdigest()==h(b/'i18n_ko/doc_notes/en/api-ko'/rel),rel
for route,needle in [('etapi','Trilium 외부 API'),('api','Trilium Notes 동기화 서버 API')]:
with urllib.request.urlopen('http://127.0.0.1:18082/'+route+'/docs/swagger-ui-init.js',timeout=5) as r:assert needle in r.read().decode(),route
with urllib.request.urlopen('http://127.0.0.1:18082/'+route+'/docs/swagger-ui-bundle.js',timeout=5) as r:assert hashlib.sha256(r.read()).hexdigest()==h(b/'i18n_ko/doc_notes/en/api-ko/swagger/swagger-ui-bundle.js')
db=sqlite3.connect('file:'+str(b/'data/document.db')+'?mode=ro',uri=True)
for row in json.loads(pathlib.Path('/tmp/trilium-korean-phase9/korean-phase9-pending.json').read_text()):assert db.execute('SELECT value FROM attributes WHERE attributeId=?',(row['attributeId'],)).fetchone()[0]==row['value']
db.close()
result={'status':'verified','apiReferencePages':5,'staticResponses':8,'swaggerRoutes':2,'noteLinks':3,'mainSha256':h(b/'patched/main.cjs'),'backup':str(sorted((b/'backups').glob('before-api-final-*'))[-1])}
(b/'i18n_ko/phase9-final-result.json').write_text(json.dumps(result));print(json.dumps(result))