36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
import xml.etree.ElementTree as ET
|
|
from pathlib import Path
|
|
|
|
from techviz.layout import build_layout
|
|
from techviz.renderers.svg import render_svg
|
|
from techviz.spec import load_spec
|
|
from techviz.validate import has_errors, validate_spec
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class RuntimeProfileTests(unittest.TestCase):
|
|
def test_every_profile_fixture_is_executable(self) -> None:
|
|
paths = sorted((ROOT / "examples/runtime-profiles").glob("*/spec.json"))
|
|
self.assertEqual(len(paths), 10)
|
|
seen_profiles: set[str] = set()
|
|
for path in paths:
|
|
with self.subTest(path=path):
|
|
spec = load_spec(path)
|
|
issues = validate_spec(spec)
|
|
self.assertFalse(has_errors(issues), issues)
|
|
svg = render_svg(spec, build_layout(spec))
|
|
ET.fromstring(svg)
|
|
self.assertNotIn("Generated from grounded VizSpec", svg)
|
|
self.assertNotIn('class="diagram-title"', svg)
|
|
seen_profiles.add(spec.profile)
|
|
self.assertEqual(len(seen_profiles), 10)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|