Files
oci-deal-accelerator/tests/test_pptx_icon_index.py
root b30a4f0d32 Diagram generation: ref-arch-driven procedure + spec validator + KB enrichment
The diagram path now follows a documented standard procedure (lookup
the closest Oracle Architecture Center reference → confirm components
→ author absolute_layout → spec validator → render → visually verify)
and ships persistent guardrails so layout regressions can't recur.

Persistent procedure changes (apply to all users, all sessions):
- tools/diagram_spec_validator.py — geometry checks (CONTAINER_TOO_THIN,
  CONTAINER_PADDING_VIOLATION, LABEL_OVERFLOW_PARENT) run BEFORE either
  renderer (drawio + PPTX). Catches the subnet-collapse / label-overflow
  bugs that the post-render drawio validator missed.
- tools/oci_diagram_gen.py + tools/oci_pptx_diagram_gen.py — call the
  spec validator before emitting any output. Adds mysql / mysql_heatwave
  type aliases.
- tools/archcenter_pattern_lookup.py — scores against cached page
  descriptions (not just the 1-line summary), supports --queries for
  multi-fragment composition, and applies synonym expansion via
  kb/architecture-center/synonyms.yaml so "LB HA cross AD" matches
  "load balancer high availability availability domain".
- kb/architecture-center/synonyms.yaml — canonical synonym table
  (load balancer, autonomous database, data guard, …) used by the
  lookup scorer.

KB enrichment:
- tools/archcenter_description_fetcher.py + 121 cached _description.md
  under kb/diagram/assets/archcenter-refs/<slug>/. Removes the runtime
  dependency on docs.oracle.com when authoring specs and feeds the
  pattern-lookup scorer.
- 110+ cached .drawio / .svg / .png references for offline reuse,
  plus the OCI Toolkit v24.2 import (kb/diagram/assets/oci-toolkit-drawio).

Documentation:
- docs/skill/output-formats.md — new "Standard diagram-generation
  procedure (MANDATORY)" + geometry rules + the new validator entry.
- SKILL.md option 2 — references the mandatory procedure.
- README.md — describes the spec validator, archcenter_pattern_lookup
  and description fetcher, and updates the KB-health table.

Tooling that backs the procedure (cumulative across recent sessions):
tools/archcenter_case_runner.py, archcenter_batch_driver.py,
archcenter_zip_downloader.py, drawio_visual_validator.py,
drawio_fidelity_eval.py, harvest_drawio_icon.py, import_oci_library.py,
oci_pptx_diagram_gen.py, oci_pptx_render.py, refresh_pptx_icon_index.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-25 21:15:21 -03:00

69 lines
2.6 KiB
Python

import sys
from pathlib import Path
PROJECT_ROOT = Path(__file__).resolve().parent.parent
TOOLS_DIR = PROJECT_ROOT / "tools"
if str(TOOLS_DIR) not in sys.path:
sys.path.insert(0, str(TOOLS_DIR))
from refresh_pptx_icon_index import DEFAULT_CONFIG_PATH, build_outputs, load_config
def test_build_outputs_detects_semantic_slides_for_bundled_oci_icons():
config = load_config(DEFAULT_CONFIG_PATH)
asset = PROJECT_ROOT / config["asset"]["bundled_path"]
index, manifest = build_outputs(asset, config)
assert asset.is_file()
assert index["library"]["slide_count"] >= 40
assert "connectors_logical" in index["semantic_slides"]
assert "grouping" in index["semantic_slides"]
assert "database_icons" in index["semantic_slides"]
assert len(index["slide_catalog"]) == index["library"]["slide_count"]
assert index["instruction_catalog"]["slide_count_with_instructions"] >= 10
assert manifest["asset"]["sha256"] == index["library"]["sha256"]
def test_build_outputs_extracts_expected_database_icon_refs():
config = load_config(DEFAULT_CONFIG_PATH)
asset = PROJECT_ROOT / config["asset"]["bundled_path"]
index, _ = build_outputs(asset, config)
icons = index["stencils"]["database_icons"]
assert "adb_d" in icons
assert "atp_d" in icons
assert "adw_d" in icons
assert "data_guard" in icons
def test_build_outputs_indexes_full_slide_and_shape_library():
config = load_config(DEFAULT_CONFIG_PATH)
asset = PROJECT_ROOT / config["asset"]["bundled_path"]
index, manifest = build_outputs(asset, config)
slide_catalog = index["slide_catalog"]
instruction_slides = {
slide["display_number"]: slide
for slide in index["instruction_catalog"]["slides"]
}
shape_library = index["shape_library"]["entries"]
assert slide_catalog[0]["display_number"] == 1
assert slide_catalog[-1]["display_number"] == index["library"]["slide_count"]
assert 10 in instruction_slides
assert 18 in instruction_slides
assert 43 in instruction_slides
assert any("Open Arrowhead style" in line for line in instruction_slides[10]["instruction_lines"])
assert any("OCI Region" in line for line in instruction_slides[18]["instruction_lines"])
assert "adb_d" in shape_library
assert "data_guard" in shape_library
assert "api_gateway" in shape_library
assert "notifications" in shape_library
assert "oci_container_engine_for_kubernetes" in shape_library
assert any(ref.get("node_path") and len(ref["node_path"]) > 1 for ref in shape_library["api_gateway"])
assert manifest["coverage"]["catalogued_slides"] == index["library"]["slide_count"]