Files
mes-demo/apis/equipment/test_oee_export.py
T

36 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- 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()