style: label Guanghan radiator panels

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
2026-07-09 17:33:57 +08:00
co-authored by Codex
parent b1a91159d9
commit 4f41976292
2 changed files with 24 additions and 0 deletions
+19
View File
@@ -54,6 +54,25 @@ class GuanghanTopologySourceTests(unittest.TestCase):
r'<(?:g|rect)[^>]+class="[^"]*radiator[^"]*"[^>]+data-module=',
)
def test_each_radiator_has_a_visible_text_label(self) -> None:
radiator_groups = re.findall(
r'<g class="radiator"[^>]*>(.*?)</g>',
self.html,
flags=re.S,
)
self.assertEqual(len(radiator_groups), 4)
for group in radiator_groups:
self.assertIn(">散热器</text>", group)
rect = re.search(r'<rect x="(\d+)" y="(\d+)" width="(\d+)"', group)
label = re.search(r'<text[^>]+x="(\d+)" y="(\d+)"[^>]*>散热器</text>', group)
self.assertIsNotNone(rect)
self.assertIsNotNone(label)
rect_x, rect_y, rect_width = map(int, rect.groups())
label_x, label_y = map(int, label.groups())
self.assertGreaterEqual(label_x, rect_x)
self.assertLessEqual(label_x, rect_x + rect_width)
self.assertLess(label_y, rect_y)
def test_future_extensions_exist_only_as_source_comments(self) -> None:
comments = "\n".join(re.findall(r"<!--(.*?)-->", self.html, flags=re.S))
visible_source = re.sub(r"<!--.*?-->", "", self.html, flags=re.S)