@seldom.file_data("test_data/device/device.yaml", key="test_importDevice")
@seldom.skip("ok")
def test_importDevice(self, file_path, code, device_name):
"""[设备导入]
"""
url = "/maicloud-manager/device/v1/importDevice"
body = {}
json_data = json.dumps(body)
param_len = len(json_data)
data_base64 = base64.b64encode(json_data.encode())
url = "https://11.0.54.20:443/api/maicloud-manager/device/v1/importDevice"
data = {
"X-Access-Token": self.browser_user.X_Access_Token,
"X-Param-Length": param_len,
"body": data_base64.decode("utf-8")
}
file_name = os.path.basename(file_path)
file = {'file': (file_name, open(file_path, "rb"),
"application/octet-stream")}
# 'file' 上传文件的键名
# file_name 上传到服务器的文件名,可以和上传的文件名不同
# open(file_path, "rb")打开的文件对象,注意文件路径正确
# "application/octet-stream" Content-Type类型
self.post(url, data=data, files=file, verify=False)
self.assertPath("code", code)