Files
Aislo/resources/tester/test_preview_assets.py
T
eomsangdonandClaude Opus 5 1a82df951f revert(tester): 서식만 바뀐 남의 시험 파일 25개 되돌림
ruff 글로브를 `resources/tester/*.py` 로 넓게 잡아 내 작업과 무관한 시험 파일까지
서식이 바뀌었음. 다른 창이 그 파일을 만지면 충돌만 남으므로 되돌림.
내가 실제로 고친 다섯(열쇠 장부·Z01 둘·표 읽기·못 읽은 표)만 남김.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsGw1Dz9HmhuAxGisxmDPF
2026-09-17 19:42:32 +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