Files
Aislo/resources/tester/test_preview_assets.py
T
eomsangdonandClaude Opus 5 d7cb14f416 test(B08): tmp/tests 중 tester 에 없던 47 개를 resources/tester 로 옮김
tmp/ 가 창끼리 안 건너가는 것이 확정돼(랩탑이 시간 두고 두 번 확인) 시험·예외가
저절로 건너가도록 git 안으로 옮김. 사용자 확정.

- 내용은 하나도 안 고침 — 자리만 옮김. tmp/tests 는 남겨 둠.
- 같은 이름이 이미 있던 64 개는 랩탑 것을 그대로 두고 건너뜀.
- helper_b05_*.js 둘은 랩탑이 .cjs 로 이미 올린 것과 **줄바꿈만 다른 같은 내용**이라
  복사본을 도로 뺌(시험이 .cjs 를 부름).
- resources/tester/ 에서 전체 1176 통과 · 29 건너뜀 · 실패 0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 17:15:57 +09:00

76 lines
2.6 KiB
Python

"""카드 미리보기 재료(라이다 점 그림·GeoTIFF 썸네일) 생성 검증 (2026-09-04 사용자 지시)."""
import asyncio
import sys
import time
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[2]
sys.path.append(str(ROOT))
PROJECT_ID = "5cff3920-a181-4a3d-bec0-e0ac4082b75d" # 용화_LAS
def _project_root() -> Path:
import aiomysql
from common_util.common_util_storage import resolve_stored_project_path
from config.config_db import DB_HOST, DB_NAME, DB_PASSWORD, DB_PORT, DB_USER
async def run():
conn = await aiomysql.connect(
host=DB_HOST, port=DB_PORT, user=DB_USER, password=DB_PASSWORD,
db=DB_NAME, charset="utf8mb4",
)
try:
async with conn.cursor(aiomysql.DictCursor) as cursor:
await cursor.execute(
"SELECT storage_path FROM projects WHERE id = %s", (PROJECT_ID,)
)
return await cursor.fetchone()
finally:
conn.close()
row = asyncio.run(run())
if not row:
pytest.skip("용화_LAS 프로젝트가 없습니다.")
return Path(resolve_stored_project_path(row["storage_path"]))
def test_las_preview_points():
from B03_FileInput.B03_FileInput_Engine_Analyze import analyze_las_metadata
root = _project_root()
files = sorted((root / "B03_FileInput" / "input" / "las").glob("*.la*"))
if not files:
pytest.skip("LAS 파일이 없습니다.")
started = time.perf_counter()
meta = analyze_las_metadata(files[0])
elapsed = time.perf_counter() - started
points = meta.get("preview_points") or []
print(f"\n{files[0].name}: 점 {meta['point_count']:,}개, 미리보기 점 {len(points)}개, {elapsed:.1f}s")
assert 0 < len(points) <= 5000
bounds = meta["bounds"]
for x, y in points[:200]:
assert bounds["x"][0] - 1 <= x <= bounds["x"][1] + 1
assert bounds["y"][0] - 1 <= y <= bounds["y"][1] + 1
def test_geotiff_thumbnail():
from B03_FileInput.B03_FileInput_Engine_Analyze import analyze_tif_metadata
root = _project_root()
files = sorted((root / "B03_FileInput" / "input" / "tif").glob("*.tif"))
if not files:
pytest.skip("GeoTIFF 파일이 없습니다.")
started = time.perf_counter()
meta = analyze_tif_metadata(files[0])
elapsed = time.perf_counter() - started
thumb = meta.get("preview_thumbnail")
print(f"{files[0].name}: 썸네일 {'있음 %d바이트' % len(thumb) if thumb else '없음(오버뷰 없음)'}, {elapsed:.1f}s")
if thumb:
assert thumb.startswith("data:image/png;base64,")
assert elapsed < 5.0