54 行
2.6 KiB
Python
54 行
2.6 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""
|
||
全站独立页面精美视觉配图规范专项测试 (Dedicated Page Illustrations Test)
|
||
严格遵循 TDD 模式:
|
||
1. 验证软件定制独立页、APP定制独立页、智能体独立页、联系我们页均配有专属高品质现代中式矢量视窗图;
|
||
2. 验证所有图片文件真实存在于资源目录且尺寸有效;
|
||
3. 验证图片符合浅色专业风规范(背景 #FFFFFF/#F8FAFC、主色 #2563EB、无 emoji、有印章点缀与细线窗棂)。
|
||
"""
|
||
import os
|
||
import unittest
|
||
|
||
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||
|
||
class TestDedicatedPageIllustrations(unittest.TestCase):
|
||
|
||
def setUp(self):
|
||
self.img_dir = os.path.join(ROOT_DIR, 'public/assets/addons/official/images/showcases')
|
||
self.template_dir = os.path.join(ROOT_DIR, 'addons/official/view/web')
|
||
|
||
def test_illustration_assets_exist(self):
|
||
"""测试 4 张专属精美视觉插图文件存在且内容有效"""
|
||
required_images = [
|
||
'service_software_hero.svg',
|
||
'service_app_hero.svg',
|
||
'service_agent_hero.svg',
|
||
'contact_headquarters.svg',
|
||
]
|
||
for img_name in required_images:
|
||
path = os.path.join(self.img_dir, img_name)
|
||
self.assertTrue(os.path.exists(path), f"缺少专属精美配图: {img_name}")
|
||
with open(path, 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
self.assertIn('<svg', content, f"{img_name} 必须是有效矢量 SVG")
|
||
self.assertIn('#2563EB', content, f"{img_name} 必须包含主色 #2563EB 科技蓝")
|
||
self.assertIn('nhc-seal', content, f"{img_name} 必须包含现代中式印章点缀")
|
||
|
||
def test_pages_embed_dedicated_illustrations(self):
|
||
"""测试各独立页面均正确嵌入对应的精美配图"""
|
||
pages = {
|
||
'software': ('official_product/service_software.html', 'service_software_hero.svg'),
|
||
'app': ('official_product/service_app.html', 'service_app_hero.svg'),
|
||
'agent': ('official_product/service_agent.html', 'service_agent_hero.svg'),
|
||
'contact_pc': ('official_online_message/list.html', 'contact_headquarters.svg'),
|
||
'contact_m': ('official_online_message/list_e.html', 'contact_headquarters.svg'),
|
||
}
|
||
for key, (tpl_rel, img_name) in pages.items():
|
||
tpl_path = os.path.join(self.template_dir, tpl_rel)
|
||
with open(tpl_path, 'r', encoding='utf-8') as f:
|
||
html = f.read()
|
||
self.assertIn(img_name, html, f"页面 {tpl_rel} 必须正确引用专属配图 {img_name}")
|
||
|
||
if __name__ == '__main__':
|
||
unittest.main()
|