Files
endorphin-tabularium-docs/tools/figures/tests/test_architecture.py
codex-bot 36840ef1d4
Verify and deploy Tabularium / verify-and-deploy (push) Has been cancelled
Separate storage shard meshes and unify Endor backup topology
2026-10-27 21:10:43 +08:00

50 lines
2.4 KiB
Python

"""Protect the topology, independent shard sets and unified backup boundary."""
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'), 10)
for i in range(1, 6):
self.assertEqual(texts.count(f'Nexus Runtime {i:02}'), 2)
for i in range(1, 3):
self.assertEqual(texts.count(f'Traefik {i}'), 2)
for prefix in ('NA', 'AS'):
for family in ('PG', 'AO', 'S3'):
for i in range(1, 4):
self.assertIn(f'{prefix}-{family}-{i:02}', texts)
paths = root.findall('.//s:path', ns)
runtime_mesh = [e for e in paths if e.get('stroke-width') == '1.35'
and e.get('opacity') == '0.65']
self.assertEqual(len(runtime_mesh), 20, 'Two complete K2,5 gateway meshes')
storage_mesh = [e for e in paths if e.get('stroke-width') == '1.15'
and e.get('opacity') == '0.55']
self.assertEqual(len(storage_mesh), 36, 'Each region has two K3,3 storage meshes')
self.assertEqual(texts.count('03 统一备份系统'), 1)
for family in ('PostgreSQL', 'Aerarium', 'S3'):
self.assertIn(f'{family} 备份', texts)
self.assertIn('… / etc', texts)
self.assertIn('其他区域', texts)
self.assertNotIn('PG + Aerarium + S3', texts)
self.assertNotIn('概念设计 · 草案', texts)
self.assertNotIn('一个全球入口,多个区域,一组可恢复的对象。', texts)
self.assertFalse(any('位于北美' in t or '位于亚洲' in t for t in texts))
self.assertEqual(root.findall('.//s:image', ns), [])
if __name__ == '__main__':
unittest.main()