Files
endorphin-tabularium-docs/tools/figures/tests/test_architecture.py
T
codex-bot 1c27f6bc1e
Verify and deploy Tabularium / verify-and-deploy (push) Successful in 4m14s
Explain Endor concepts with a reproducible multi-region topology
2026-10-27 17:45:30 +08:00

39 lines
1.8 KiB
Python

"""Protect the relationships that make this a topology rather than a block chart."""
from pathlib import Path
import tempfile
import unittest
import xml.etree.ElementTree as ET
from endor_figures.architecture import build_architecture
class ArchitectureTest(unittest.TestCase):
def test_topology_and_reproducibility(self):
with tempfile.TemporaryDirectory() as directory:
first, second = (Path(directory) / name for name in ('first.svg', 'second.svg'))
build_architecture(first)
build_architecture(second)
self.assertEqual(first.read_bytes(), second.read_bytes())
root = ET.parse(first).getroot()
ns = {'s': 'http://www.w3.org/2000/svg'}
texts = [''.join(e.itertext()) for e in root.findall('.//s:text', ns)]
self.assertEqual(texts.count('Aster VM'), 6)
for i in range(1, 4):
self.assertEqual(texts.count(f'Nexus Runtime {i}'), 2)
for i in range(1, 3):
self.assertEqual(texts.count(f'Traefik {i}'), 2)
for prefix in ('NA', 'AS'):
for i in range(1, 3):
self.assertIn(f'{prefix}-{i:02} / 数据分片', texts)
self.assertIn(f'{prefix}-{i:02} 备份集', texts)
mesh_edges = [e for e in root.findall('.//s:path', ns)
if e.get('stroke-width') == '1.35' and e.get('opacity') == '0.65']
self.assertEqual(len(mesh_edges), 12, 'Each region must retain the full K2,3 mesh')
# The figure must remain self-contained and editable.
self.assertEqual(root.findall('.//s:image', ns), [])
self.assertIn('异步复制 / 版本化备份', texts)
if __name__ == '__main__':
unittest.main()