85 lines
2.2 KiB
Python
85 lines
2.2 KiB
Python
|
|
#!/usr/bin/env python3
|
|||
|
|
"""
|
|||
|
|
最终测试:验证新配置是否工作
|
|||
|
|
datatype: Breaker
|
|||
|
|
field: load_status
|
|||
|
|
"""
|
|||
|
|
|
|||
|
|
import subprocess
|
|||
|
|
import time
|
|||
|
|
|
|||
|
|
def test_data_write():
|
|||
|
|
"""测试数据写入"""
|
|||
|
|
print("测试数据写入功能")
|
|||
|
|
print("-" * 30)
|
|||
|
|
|
|||
|
|
try:
|
|||
|
|
# 测试写入状态1
|
|||
|
|
result = subprocess.run(
|
|||
|
|
['python', 'quick_test_data.py'],
|
|||
|
|
input='3\n',
|
|||
|
|
text=True,
|
|||
|
|
capture_output=True,
|
|||
|
|
timeout=10
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
if result.returncode == 0:
|
|||
|
|
print("OK 状态1写入成功")
|
|||
|
|
print(f"输出: {result.stdout.strip()}")
|
|||
|
|
else:
|
|||
|
|
print(f"ERROR 状态1写入失败: {result.stderr}")
|
|||
|
|
return False
|
|||
|
|
|
|||
|
|
time.sleep(2)
|
|||
|
|
|
|||
|
|
# 测试写入状态0
|
|||
|
|
result = subprocess.run(
|
|||
|
|
['python', 'quick_test_data.py'],
|
|||
|
|
input='2\n',
|
|||
|
|
text=True,
|
|||
|
|
capture_output=True,
|
|||
|
|
timeout=10
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
if result.returncode == 0:
|
|||
|
|
print("OK 状态0写入成功")
|
|||
|
|
print(f"输出: {result.stdout.strip()}")
|
|||
|
|
else:
|
|||
|
|
print(f"ERROR 状态0写入失败: {result.stderr}")
|
|||
|
|
return False
|
|||
|
|
|
|||
|
|
return True
|
|||
|
|
|
|||
|
|
except Exception as e:
|
|||
|
|
print(f"ERROR 测试失败: {e}")
|
|||
|
|
return False
|
|||
|
|
|
|||
|
|
def main():
|
|||
|
|
print("最终测试 - 新配置验证")
|
|||
|
|
print("datatype: Breaker, field: load_status")
|
|||
|
|
print("=" * 50)
|
|||
|
|
|
|||
|
|
# 测试数据写入
|
|||
|
|
write_ok = test_data_write()
|
|||
|
|
|
|||
|
|
print("\n" + "=" * 50)
|
|||
|
|
print("测试结果:")
|
|||
|
|
|
|||
|
|
if write_ok:
|
|||
|
|
print("SUCCESS 所有测试通过!")
|
|||
|
|
print("\n修改总结:")
|
|||
|
|
print("1. default.json: measurement = 'Breaker'")
|
|||
|
|
print("2. ui_main.py: 监控器配置使用 'load_status' 字段")
|
|||
|
|
print("3. quick_test_data.py: 写入 'load_status' 字段到 'Breaker' measurement")
|
|||
|
|
|
|||
|
|
print("\n下一步:")
|
|||
|
|
print("1. 重启程序进行实际测试")
|
|||
|
|
print("2. 创建工单并进入等待状态")
|
|||
|
|
print("3. 执行状态变化测试")
|
|||
|
|
print("4. 观察监控器是否检测到变化")
|
|||
|
|
else:
|
|||
|
|
print("ERROR 测试失败,请检查配置")
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
main()
|