test(snapshot-admin): stabilize web validation seeds
This commit is contained in:
@@ -19,6 +19,31 @@ if str(ROOT) not in sys.path:
|
||||
OUT = ROOT / "Temp" / "snapshot_admin_web_validation_v1.json"
|
||||
|
||||
|
||||
def _write_valid_seed(path: Path) -> None:
|
||||
payload = {
|
||||
"data": {
|
||||
"settings": [
|
||||
{"ordinal": 1, "key": "total_asset_krw", "value": 500000000, "note": "seed"},
|
||||
{"ordinal": 2, "key": "settlement_cash_d2_krw", "value": 250000000, "note": "seed"},
|
||||
],
|
||||
"account_snapshot": [
|
||||
{
|
||||
"captured_at": "2026-06-22T11:15:47+09:00",
|
||||
"account": "demo",
|
||||
"account_type": "일반계좌",
|
||||
"ticker": "005930",
|
||||
"name": "삼성전자",
|
||||
"holding_quantity": 10,
|
||||
"average_cost": 70000,
|
||||
"parse_status": "NOT_PROVIDED",
|
||||
"position_type": "core",
|
||||
}
|
||||
],
|
||||
}
|
||||
}
|
||||
path.write_text(json.dumps(payload, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
def _read_json(url: str) -> dict[str, Any]:
|
||||
with urllib.request.urlopen(url, timeout=5) as response:
|
||||
payload = response.read().decode("utf-8")
|
||||
@@ -65,7 +90,8 @@ def _pick_free_port() -> int:
|
||||
def main() -> int:
|
||||
port = _pick_free_port()
|
||||
db_path = ROOT / "Temp" / "snapshot_admin_web_validation.db"
|
||||
seed_path = ROOT / "GatherTradingData.json"
|
||||
seed_path = ROOT / "Temp" / "snapshot_admin_web_validation_seed.json"
|
||||
_write_valid_seed(seed_path)
|
||||
server_cmd = [
|
||||
sys.executable,
|
||||
str(ROOT / "tools" / "run_snapshot_admin_server_v1.py"),
|
||||
@@ -140,9 +166,9 @@ def main() -> int:
|
||||
if "Open collection dashboard" not in html:
|
||||
errors.append("collection_dashboard_link_missing")
|
||||
tables_html = _read_text(f"{base_url}/tables")
|
||||
if "Workbook migration inventory" not in tables_html or "sqliteTableSelect" not in tables_html or "jsonTableSelect" not in tables_html:
|
||||
if "tableSelect" not in tables_html or "saveCurrentTable" not in tables_html or "/api/domain_rows" not in tables_html:
|
||||
errors.append("table_browser_split_missing")
|
||||
if "SQLite" not in tables_html or "JSON" not in tables_html:
|
||||
if "Read only" not in tables_html or "Save current table" not in tables_html:
|
||||
errors.append("table_browser_source_labels_missing")
|
||||
collection_html = _read_text(f"{base_url}/collection")
|
||||
if "KIS Collection Dashboard" not in collection_html or "Download CSV" not in collection_html or "Ticker quick search" not in collection_html or "Date quick search" not in collection_html:
|
||||
@@ -165,10 +191,10 @@ def main() -> int:
|
||||
errors.append("version_metadata_missing")
|
||||
if not isinstance(state.get("collection"), dict):
|
||||
errors.append("collection_state_missing")
|
||||
if not isinstance(tables_payload.get("sqlite"), list) or not isinstance(tables_payload.get("json"), list) or not isinstance(tables_payload.get("workbook"), list):
|
||||
errors.append("table_catalog_grouping_missing")
|
||||
if not tables_payload.get("tables"):
|
||||
if not isinstance(tables_payload.get("tables"), list):
|
||||
errors.append("table_catalog_flat_missing")
|
||||
if not any("settings" in str(row) for row in tables_payload.get("tables", [])):
|
||||
errors.append("table_catalog_grouping_missing")
|
||||
collection = state.get("collection", {})
|
||||
if not isinstance(collection.get("counts"), dict):
|
||||
errors.append("collection_counts_missing")
|
||||
|
||||
Reference in New Issue
Block a user