52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[1]
|
|
DEMO_PATH = PROJECT_ROOT / "data" / "wiki" / "guanghan_topology_demo.html"
|
|
GHC05_PATH = PROJECT_ROOT / "data" / "wiki" / "guanghan_ghc05_zh.html"
|
|
|
|
|
|
class WikiTopologyProxyTests(unittest.TestCase):
|
|
def test_demo_derives_api_prefix_from_document_url(self):
|
|
html = DEMO_PATH.read_text(encoding="utf-8")
|
|
|
|
self.assertIn("new URL('.', window.location.href).pathname", html)
|
|
self.assertIn("replace(/\\/$/, '')", html)
|
|
|
|
def test_ghc05_embed_uses_public_proxy_instead_of_private_backend(self):
|
|
html = GHC05_PATH.read_text(encoding="utf-8")
|
|
public_url = (
|
|
"http://118.89.192.134:59100/topology/"
|
|
"guanghan_topology_demo.html?mission=GHC-05"
|
|
)
|
|
|
|
self.assertEqual(html.count(public_url), 2)
|
|
self.assertNotIn("192.168.195.241:38080", html)
|
|
|
|
def test_ghc05_uses_wikipedia_article_structure(self):
|
|
html = GHC05_PATH.read_text(encoding="utf-8")
|
|
|
|
self.assertEqual(html.count('<h1 id="top">'), 1)
|
|
self.assertNotIn('<nav class="toc"', html)
|
|
self.assertIn("body:has(.wiki-article) .page-header-section", html)
|
|
self.assertIn("body:has(.wiki-article) .page-col-sd", html)
|
|
self.assertIn("top: 118px !important", html)
|
|
self.assertIn(".wiki-article h2 { clear: none; overflow: hidden;", html)
|
|
self.assertEqual(html.count('class="infobox-overlap-section"'), 2)
|
|
self.assertIn('class="infobox-label"', html)
|
|
self.assertEqual(html.count('class="wikitable"'), 2)
|
|
self.assertIn('<figure class="topology-embed-shell">', html)
|
|
|
|
def test_ghc05_has_no_peripheral_ring_walkway(self):
|
|
html = GHC05_PATH.read_text(encoding="utf-8")
|
|
|
|
self.assertNotIn("四段加压走道", html)
|
|
self.assertNotIn("外围互联互通", html)
|
|
self.assertNotIn("居住舱段一号至二号", html)
|
|
self.assertIn("舱段外围没有环形加压走道", html)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|