- 원본 BookData 7권 해독(DBISAM 암호 표 Blowfish-CBC, zlib RTF) 서버 book-store.cjs, /api/book 경로 - 목차 트리·본문 표·제목/본문/키워드 검색·본문 강조·복사하기, 단가산출·내역·일위·기계 붙여넣기 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.8 KiB
Python
44 lines
1.8 KiB
Python
"""EST 테스트 앱 품셈 보기(원본 BookData 암호 표 해독 · 목차 · 본문 · 검색)."""
|
|
|
|
import json
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
BOOK = Path("C:/Dasansoft/Est Plus 2/System/BookData/forest.dat")
|
|
|
|
|
|
def node(code: str):
|
|
return json.loads(subprocess.check_output(["node", "-e", code], cwd=ROOT).decode("utf-8"))
|
|
|
|
|
|
def test_blowfish_constants_and_rtf_text():
|
|
out = node(r"""
|
|
const b = require('./tools/est-test/book-store.cjs');
|
|
const w = b.piWords(1042);
|
|
const rtf = Buffer.from(String.raw`{\rtf1{\fonttbl{\f0 x;}}\'b0\'a1\cell 1.2\row \u44032?\par}`, 'latin1');
|
|
process.stdout.write(JSON.stringify({ p0: w[0].toString(16), last: w[1041].toString(16), text: b.rtfText(rtf) }));
|
|
""")
|
|
assert out["p0"] == "243f6a88"
|
|
assert out["last"] == "3ac372e6" # Blowfish S4[255]
|
|
assert out["text"] == "가\t1.2\n가\n"
|
|
|
|
|
|
def test_installed_forest_book():
|
|
if not BOOK.exists():
|
|
pytest.skip("installed EST book data unavailable")
|
|
out = node(r"""
|
|
const b = require('./tools/est-test/book-store.cjs');
|
|
const list = b.list(), tree = b.tree('forest'), page = b.text('forest', 902);
|
|
process.stdout.write(JSON.stringify({ books: list.map((x) => x.name), forest: list.find((x) => x.name === 'forest'),
|
|
nodes: tree.length, page: page.text.split('\n').filter((l) => l.startsWith('1.0 이하'))[0],
|
|
title: b.search('forest', '교목 굴취').map((h) => h.pkid), body: b.search('forest', '근원직경을', 'body').length }));
|
|
""")
|
|
assert out["books"] == ["civil", "archit", "machine", "electric", "culture", "forest", "woods"]
|
|
assert out["forest"]["desc"].startswith("산림품셈(2026)") and out["forest"]["nodes"] == 563
|
|
assert out["page"] == "1.0 이하\t0.072\t0.012\t"
|
|
assert 902 in out["title"]
|
|
assert out["body"] >= 1
|