You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
"""
无人机决策系统 - AnalysisEngine 单元测试模板
作者:刘宇杰
日期: 2025-07-13
"""
import unittest
from core . analysis import AnalysisEngine
class TestAnalysisEngine ( unittest . TestCase ) :
def setUp ( self ) :
""" 初始化分析引擎实例 """
self . engine = AnalysisEngine ( )
def test_analyze_text ( self ) :
""" 测试文本分析功能(示例) """
text = " 5点钟方向, 有三辆敌方坦克和20名敌军 "
filename = " test.txt "
result = self . engine . analyze_text ( text , filename )
self . assertIn ( " type " , result )
self . assertIn ( " ernie_analysis " , result )
def test_analyze_image ( self ) :
""" 测试图像分析功能(示例,需提供有效图片数据) """
# 这里只做接口调用示例,实际应传入有效图片二进制数据
image_data = b " fake_image_data "
filename = " test.jpg "
result = self . engine . analyze_image ( image_data , filename )
self . assertIn ( " type " , result )
self . assertIn ( " ernie_analysis " , result )
def test_generate_strike_plan ( self ) :
""" 测试打击计划生成功能(示例) """
analysis_results = [
{ " ernie_analysis " : { " 兵力构成 " : " 三辆坦克, 20名步兵 " } , " type " : " text " }
]
result = self . engine . generate_strike_plan ( analysis_results )
self . assertIsInstance ( result , dict )
if __name__ == " __main__ " :
unittest . main ( )