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
+53
View File
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
"""模具管理用例。
业务链路:先查设备(dao),再按设备批量建模具(接口)。
"""
import unittest
from core import auth, config
from core.http_client import HttpClient
from core.logger import setLog
from dao.equipment import EquipmentDao
class TestMold(unittest.TestCase):
@classmethod
def setUpClass(cls):
auth.login()
cls.http = HttpClient()
@setLog()
def test_mold_add(self):
"""按设备批量建模具"""
dao = EquipmentDao()
devices = dao.get_devices()
self.assertGreaterEqual(len(devices), 1)
url = config.base_url() + '/mes/mold/add'
results = []
for dev in devices:
payload = {
'name': '演示模具-{0}'.format(dev.id),
'serialNum': str(dev.id),
'specifications': '',
'moldDeviceIDs': [str(dev.id)],
}
body = self.http.post_json(url, payload).json()
self.assertEqual(body['code'], 200)
results.append(body)
dao.close()
return results
@setLog()
def test_mold_add_empty_name(self):
"""新增模具-名称为空"""
url = config.base_url() + '/mes/mold/add'
body = self.http.post_json(url, {'name': ''}).json()
self.assertEqual(body['code'], 400)
self.assertEqual(body['message'], '模具名称不能为空')
return body
if __name__ == '__main__':
unittest.main()