Commit e6e05ada authored by 刘丙寅's avatar 刘丙寅

om后台接口提交

parent be3b8486
This diff is collapsed.
......@@ -135,44 +135,44 @@ if __name__ == "__main__":
# 生成测试报告的路径
error_count,failure_count = run_case(all_case) # 2执行用例
bug_number = int(error_count) + int(failure_count)
if bug_number!=0:
# 获取最新的测试报告文件
report_path = os.path.join(cur_path, "report") # 用例文件夹
report_file = get_report_file(report_path) # 3获取最新的测试报告
# #邮箱配置 发送邮箱的地址
# sender = "l709188456@163.com"
sender = "liubingyin@igengmei.com"
#邮箱密码
#psw = "3328378"
psw = "cgBP3fw2ZNgp3L5r"
# 163服务器的servers
#smtp_server = "smtp.163.com"
#公司地址的服务器server
smtp_server = "smtp.exmail.qq.com"
port = 465
#发给谁的邮箱
receiver = ["liubingyin@igengmei.com", "chenxiangxiang@igengmei.com"]
send_mail(sender, psw, receiver, smtp_server, report_file, port) # 4最后一步发送报告
dd_url = "https://oapi.dingtalk.com/robot/send?access_token=4aa12245f7b6c273dde43c4a547b386cd12dc59f22a475f2efbd494094be15b9"
text = "监控报警:接口出现异常,请查看邮件排查问题"
json_text = {
"msgtype": "text",
"at": {
"atMobiles": [
# 变为所有人 这里要改
"all"
],
# 变为true 就会@所有人
#"isAtAll": False
"isAtAll": True
},
"text": {
"content": text
}
}
requests.post(url=dd_url, json=json_text, verify=False)
else:
print("无问题 不发送测试报告哦")
# if bug_number!=0:
# # 获取最新的测试报告文件
# report_path = os.path.join(cur_path, "report") # 用例文件夹
#
# report_file = get_report_file(report_path) # 3获取最新的测试报告
# # #邮箱配置 发送邮箱的地址
# # sender = "l709188456@163.com"
# sender = "liubingyin@igengmei.com"
# #邮箱密码
# #psw = "3328378"
# psw = "cgBP3fw2ZNgp3L5r"
# # 163服务器的servers
# #smtp_server = "smtp.163.com"
# #公司地址的服务器server
# smtp_server = "smtp.exmail.qq.com"
# port = 465
# #发给谁的邮箱
# receiver = ["liubingyin@igengmei.com", "chenxiangxiang@igengmei.com"]
# send_mail(sender, psw, receiver, smtp_server, report_file, port) # 4最后一步发送报告
# dd_url = "https://oapi.dingtalk.com/robot/send?access_token=4aa12245f7b6c273dde43c4a547b386cd12dc59f22a475f2efbd494094be15b9"
# text = "监控报警:接口出现异常,请查看邮件排查问题"
# json_text = {
# "msgtype": "text",
# "at": {
# "atMobiles": [
# # 变为所有人 这里要改
# "all"
# ],
# # 变为true 就会@所有人
# #"isAtAll": False
# "isAtAll": True
# },
# "text": {
# "content": text
# }
# }
#
# requests.post(url=dd_url, json=json_text, verify=False)
#
# else:
# print("无问题 不发送测试报告哦")
import requests
import sys,os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import unittest
from interface import interface
from requests.cookies import cookiejar_from_dict
from pprint import pprint
from ddt import ddt,data
import jsonpath
import yaml
#获取上级目录路径
path = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
# 拼接需要的目录
path = os.path.join(path,"test_yaml","zhuanzhen_celue.yaml")
# 打开文件夹 读取数据
file1 = open(path,'r', encoding="utf-8")
file2 = file1.read()
file3 = yaml.load(file2)
print("所有数据列表陈列:开始")
pprint(file3)
print("所有数据列表陈列:结束"+ '\n')
@ddt
class Case(unittest.TestCase):
@data(*file3)
def test_01_zhuanzhen_celue_test(self,contents):
'转诊策略派单召回数据校验'
print("预期响应数据:开始")
pprint(contents)
print("预期响应数据:结束")
URL = interface.hera_host+interface.recommend_hospitals
body = contents.get("request").get("body")
cookies = interface.hera_cookies
result = requests.post(url=URL, cookies=cookiejar_from_dict(cookies), data=body, verify=False)
res = result.json()
print("实际返回数据:开始")
pprint(res)
print("实际返回数据:结束")
response = contents.get("request").get("response")
for k,v in response.items():
# k是配置参数里面的路径 通过k设定 去res里面找到实际的数据。 由于jsonpath返回的是一个列表 所以要用【0】处理。返回回去的就是一个取出来的数值 eg:"data.0.doctor_id"
res_response = jsonpath.jsonpath(res,k)[0]
v = eval(v)
# assertmethod = self.assertEqual/self.assertIsInstance 取决于上面参数内写的是什么方法。 作用: getattr(object, name) = object.name
for i in range(len(v)):
assertmethod = getattr(self,v[i][0])
assertmethod(res_response,v[i][1])
import requests
import unittest
from interface import interface
from ddt import ddt,data
import os
from pprint import pprint
import yaml
from requests.cookies import cookiejar_from_dict
import jsonpath
import json
#获取上级目录路径
path = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
# 拼接需要的目录
path = os.path.join(path,"test_yaml","customer_pool.yaml")
# 打开文件夹 读取数据
file1 = open(path,'r', encoding="utf-8")
file2 = file1.read()
file3 = yaml.load(file2)
# print("所有数据列表陈列:开始")
# pprint(file3)
# print("所有数据列表陈列:结束"+ '\n')
#
@ddt
class Case(unittest.TestCase):
@data(*file3)
def test_01_customer_pool(self,contents):
'客服客户池列表页接口'
# print("预期响应数据:开始")
# pprint(contents)
# print("预期响应数据:结束")
URL = interface.hera_host+interface.customer_pool_interface
body = contents.get("request").get("body")
body = str(body).replace('True',"'true'").replace('False',"'false'").replace('None',"''")
print(body)
cookies = interface.hera_cookies
result = requests.post(url=URL, cookies=cookiejar_from_dict(cookies), data=eval(body),verify=False)
res = result.json()
print("实际返回数据:开始")
pprint(res)
print("实际返回数据:结束")
response = contents.get("request").get("response")
for k, v in response.items():
# k是配置参数里面的路径 通过k设定 去res里面找到实际的数据。 由于jsonpath返回的是一个列表 所以要用【0】处理。返回回去的就是一个取出来的数值 eg:"data.0.doctor_id"
res_response = jsonpath.jsonpath(res, k)[0]
v = eval(v)
# assertmethod = self.assertEqual/self.assertIsInstance 取决于上面参数内写的是什么方法。 作用: getattr(object, name) = object.name
for i in range(len(v)):
assertmethod = getattr(self, v[i][0])
assertmethod(res_response, v[i][1])
import requests
import unittest
from interface import interface
from ddt import ddt,data
import os
from pprint import pprint
import yaml
from requests.cookies import cookiejar_from_dict
import jsonpath
import json
#获取上级目录路径
path = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
# 拼接需要的目录
path = os.path.join(path,"test_yaml","modify.yaml")
# 打开文件夹 读取数据
file1 = open(path,'r', encoding="utf-8")
file2 = file1.read()
file3 = yaml.load(file2)
# print("所有数据列表陈列:开始")
# pprint(file3)
# print("所有数据列表陈列:结束"+ '\n')
#
@ddt
class Case(unittest.TestCase):
@data(*file3)
def test_01_customer_pool(self,contents):
'线索详情页接口'
# print("预期响应数据:开始")
# pprint(contents)
# print("预期响应数据:结束")
URL = interface.hera_host+interface.modify
body = contents.get("request").get("body")
print(body)
cookies = interface.hera_cookies
header = {
"content-type":"text/html"
}
result = requests.post(url=URL, cookies=cookiejar_from_dict(cookies), data=body,verify=False,headers=header)
print(result)
res = result.text
print(res)
import requests
import sys,os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import unittest
from interface import interface
from requests.cookies import cookiejar_from_dict
from pprint import pprint
from ddt import ddt,data
import jsonpath
import yaml
#获取上级目录路径
path = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
# 拼接需要的目录
path = os.path.join(path,"test_yaml","om_distribution.yaml")
# 打开文件夹 读取数据
file1 = open(path,'r', encoding="utf-8")
file2 = file1.read()
file3 = yaml.load(file2)
print("所有数据列表陈列:开始")
pprint(file3)
print("所有数据列表陈列:结束"+ '\n')
@ddt
class case(unittest.TestCase):
@data(*file3)
def test_01_distribution_list(self,contents):
'om后台客服客户池已分配客户列表接口'
URL = interface.om_host + interface.om_distribution_list
body = contents.get("request").get("body")
cookies = interface.om_cookies
result = requests.get(url=URL,cookies=cookies,params=body,verify=False)
res = result.json()
print("真实数据返回开始")
pprint(res)
print("真实数据返回结束")
response = contents.get("request").get("response")
for k, v in response.items():
# k是配置参数里面的路径 通过k设定 去res里面找到实际的数据。 由于jsonpath返回的是一个列表 所以要用【0】处理。返回回去的就是一个取出来的数值 eg:"data.0.doctor_id"
res_response = jsonpath.jsonpath(res, k)[0]
v = eval(v)
# assertmethod = self.assertEqual/self.assertIsInstance 取决于上面参数内写的是什么方法。 作用: getattr(object, name) = object.name
for i in range(len(v)):
assertmethod = getattr(self, v[i][0])
assertmethod(res_response, v[i][1])
import requests
import unittest
from assert_page import assert_method
import assert_page
from interface import interface
from requests.cookies import cookiejar_from_dict
from pprint import pprint
class Case(unittest.TestCase):
def test_01(self):
'转诊策略派单召回数据校验'
host = interface.host
url = interface.recommend_hospitals
URL = host+url
body = {
# "csrfmiddlewaretoken": "zouDYgAdEXBpk14W7SSk6UQMnxbJa3IQFKnfBtPOHG89s3bqZhYmb6ntKrmcpQZ0",
"city_id": "beijing",
"bdtransfer_id": 115792,
"size": 6,
"accept_near_city": 1
}
cookies = {"session_key": "nobskse0lscrgyj1iw3294h9lt0dbp7m"}
result = requests.post(url=URL, cookies=cookiejar_from_dict(cookies), data=body, verify=False)
assert_method.status_code(result)
res = result.json()
pprint(res)
res = res.get("data")
resl = len(res)
assert resl == 6,"转诊策略派单数据不足6条 获取到:%s" %resl
\ No newline at end of file
# 域名呈现
host = "https://hera.igengmei.com"
hera_host = "https://hera.igengmei.com"
hera_cookies = {"session_key": "nobskse0lscrgyj1iw3294h9lt0dbp7m"}
om_host = "https://om.igengmei.com"
om_cookies = {"session_key":"fnvqmeqpe6aqn8jim2o21afb2z4uthkr"}
# 转诊策略派单召回数据校验接口
recommend_hospitals = "/bdtransfer/recommend_hospitals/"
#客服客户池列表接口
customer_pool_interface = "/big/datatable/gaia/bdtransfer"
# 线索详情页接口
modify = "/bdtransfer/modify/186363/?is_private=0"
# om后台客服客户池已分配客户列表接口
om_distribution_list = "/achelous/api/bdtransfer/consultant_list"
This diff is collapsed.
This diff is collapsed.
-
request:
body:
csrfmiddlewaretoken: 59TdyPCO5Q9Ilb7irriJE6s4xsMpaEbHi9UGk7rUdYurBPo31ThSmQlhpCUE41nn
bdtransfer_id: 186363
user: 刘丙寅自动化测试
source: 58
qq: 709188456
wechat_nickname: 其实很简单1
user_phone: ["176016251171"]
wechat: ["其实很简单"]
weibo: 小饼呀6
email:
call_phone:
user_province:
gender: 0
comments:
age:
willing_projects: [{"opt":null,"start_time":"","end_time":"","comment":""}]
creator: 33077773
old_phone:
old_datetime:
potential_assess: 0
consume_potential_min: 0
consume_potential_max: 0
intention: 0
project_start_time:
project_end_time:
project_data:
-
request:
body:
bdtransfer_type: 3
page: 1
size: 20
response:
data.kefu_list[0].assigner: (("assertIsInstance",(str,)),("assertNotEqual",""))
data.kefu_list[1].assigner: (("assertIsInstance",(str,)),("assertNotEqual",""))
data.kefu_list[2].assigner: (("assertIsInstance",(str,)),("assertNotEqual",""))
-
request:
body:
city_id: beijing
bdtransfer_id: 115792
size: 6
accept_near_city: "0"
response:
code: (("assertEqual",0),)
data.0.doctor_id: (("assertIsInstance",(int,str)),)
data.0.city.name: (("assertIn",("北京","天津")),("assertIsInstance",(str,)))
-
request:
body:
city_id: beijing
bdtransfer_id: 115792
size: 6
accept_near_city: "1"
response:
code: (("assertEqual",0),)
data.0.doctor_id: (("assertIsInstance",(int,str)),)
data.0.city.name: (("assertIsInstance",(str,)),)
{"last_check":"2021-03-04T02:36:42Z","pypi_version":"21.0.1"}
\ No newline at end of file
{"last_check":"2021-05-27T02:36:08Z","pypi_version":"21.1.2"}
\ No newline at end of file
Markdown is supported
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