代码拉取完成,页面将自动刷新
同步操作将从 谢聪/python 接口自动化 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# -*- coding: utf-8 -*-
# @Author : supassxu
# @time : 2021/4/29 10:26
# @File : locust_attestation1.py
# @Software : interface_test_dataqin
import time
from locust import TaskSet, task, HttpUser
class MyTasks(TaskSet):
"""
创建测试任务类,需要继承TaskSet
可以添加多个测试任务
"""
@task(1)
def attestation_attestations(self):
# 生成存证数据(表格)接口
requestId = str(int(time.time()*1000))
try:
url = "http://192.168.253.185:8081/preposition/attestation/attestations"
payload = {
"requestId": requestId,
"tonce": 15451,
"parameterLoad": "{\"attachments\":{\"back\":{\"fileUrl\":\"202103/1617171644091478_原告授权委托书.pdf\"}},\"business\":{\"businessSerialNumber\":\"" + requestId + "\",\"certificateName\":\"" + "auto" + requestId + "\",\"certificateNumber\":\"913306216725921760\",\"certificateType\":\"1\",\"contractNo\":\"" + requestId + "\",\"organizationName\":\"渣打银行\",\"productNumber\":\"test_temple\",\"organizationNumber\":\"913306216725921760\"},\"factoid\":{\"data\":{\"name\":\"" + "auto" + requestId + "\",\"type\":\"身份证\",\"number\":\"230111197104266110\",\"phone\":\"18658176223\",\"back\":\"21212121\"},\"type\":\"11\"},\"templateId\":\"CZ-00032\"}",
"signature": "11"
}
header = {"Content-Type": "application/json"}
res = self.client.post(url, headers=header, json=payload).json()
# print(res)
if res['flag'] is True:
print("success")
else:
print("fails")
# return res
except Exception as e:
print(e)
# @task(11)
# def attestation_info(self):
# # 存证结果校验接口
# try:
# url = "http://192.168.253.185:8081/preposition/attestation/info"
# payload = {
# "uscId": "913306216725921760",
# "id": requestId,
# "flag": 0
# }
# header = {"Content-Type": "application/json"}
# res = self.client.post(url, headers=header, json=payload).json()
# # print(res)
# if res['flag'] is True:
# print("success")
# else:
# print("fails")
# # return res
# except Exception as e:
# print(e)
#
# @task(21)
# def attestation_test(self):
# # 快速生成存证数据的区块链文件及hash接口
# try:
# url = "http://192.168.253.185:8081/preposition/attestation/test"
# res = self.client.get(url).json()
# # print(res)
# if res['flag'] is True:
# print("success")
# else:
# print("fails")
# except Exception as e:
# print(e)
# 每个测试任务,往往会以实例方法的形式来呈现
# 同时需要使用task装饰器来装饰测试任务
class websitUser(HttpUser):
"""
创建运行测试类,需要继承Locust父类
"""
tasks = [MyTasks] # 指定测试任务类,使用task_set覆盖父类的类属性
min_wait = 2000 # 指定启动任务间隔的时间范围(单位毫秒):2~5秒之间
max_wait = 5000 # 使用min_wait、max_wait覆盖父类的类属性
if __name__ == "__main__":
import os
os.system("locust -f locust_attestation1.py --host=http://192.168.253.185:8081")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。