Commit 2746f191 authored by liguangyu06's avatar liguangyu06
Browse files

用例优化

parent 5dc81e0a
...@@ -22,7 +22,7 @@ cmdc_access_token = CmdcMaiiLogin(username, password).get_token() ...@@ -22,7 +22,7 @@ cmdc_access_token = CmdcMaiiLogin(username, password).get_token()
headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token) headers = commonFuc().get_business_data(module, "json_headers1", cmdc_access_token)
# 设置需要查询的生产厂家 # 设置需要查询的生产厂家
manufacturer = "A" manufacturer = "B"
# 第二步进行生产厂家模糊查询 # 第二步进行生产厂家模糊查询
url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url7") url = commonFuc().get_api_url() + commonFuc().get_business_data(module, "url7")
request_body = commonFuc().get_business_data(module, "payload7", manufacturer) request_body = commonFuc().get_business_data(module, "payload7", manufacturer)
...@@ -36,11 +36,18 @@ request_body = commonFuc().get_business_data(module, "payload7", manufacturer) ...@@ -36,11 +36,18 @@ request_body = commonFuc().get_business_data(module, "payload7", manufacturer)
# 发送请求 # 发送请求
result = requests.post(url, json=request_body, headers=headers) result = requests.post(url, json=request_body, headers=headers)
result = json.loads(result.content) result = json.loads(result.content)
print(result) # print(result)
# 获取查询结果中厂家信息 if result["data"]:
result = {"data": result["data"][0][0]} # 获取查询结果中厂家信息
# 获取预期结果 result = {"data": result["data"][0][0]}
check_dict = commonFuc().get_business_data(module, "checkDict7", manufacturer) # 获取预期结果
# print(check_dict) check_dict = commonFuc().get_business_data(module, "checkDict7", manufacturer)
# 断言实际结果中是否包含预期结果的内容 # print(check_dict)
commonFuc().check_result(check_dict, result) # 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
else:
# 获取预期结果
check_dict = commonFuc().get_business_data(module, "checkDict7", manufacturer)
# print(check_dict)
# 断言实际结果中是否包含预期结果的内容
commonFuc().check_result(check_dict, result)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment