feat: MES 接口自动化测试框架(unittest + HTMLTestRunner + 数据驱动)

This commit is contained in:
WbiubiuW
2026-09-22 14:29:22 +08:00
commit ce0bf42e04
45 changed files with 1463 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""设备管理-OEE 导出用例。
覆盖 post_file(multipart 上传)与二进制响应两种场景。
"""
import io
import unittest
from core import auth, config
from core.http_client import HttpClient
from core.logger import setLog
class TestOeeExport(unittest.TestCase):
@classmethod
def setUpClass(cls):
auth.login()
cls.http = HttpClient()
@setLog()
def test_device_export(self):
"""设备 OEE 导出:上传模板文件,断言返回文件流"""
url = config.base_url() + '/mes/device/export'
# 用内存合成文件构造上传内容,不依赖磁盘上的 Excel 模板
files = {'file': ('oee_template.csv', io.BytesIO(b'date,oee\n2026-09-01,85.5\n'),
'text/csv')}
result = self.http.post_file(url, files)
self.assertEqual(result.status_code, 200)
self.assertIn('attachment', result.headers.get('Content-Disposition', ''))
self.assertIn(b'demo-device-01', result.content)
return {'bytes': len(result.content)}
if __name__ == '__main__':
unittest.main()