Commit cabd450c authored by zhanhuasheng's avatar zhanhuasheng

兼容接口超限

parent bea9a5a1
......@@ -5,10 +5,7 @@ from Utils.config_handler import base_config
class accountData(Global):
origin_language = 'en' #原始语言
target_language = 'zh-CN' #要翻译的语言
old_name = 'zhs' #旧名字
new_name = 'auto_test' #新名字
trans_key = 'account.account'
accountData_sql_handler = SqlHandler(address=base_config.get_value('mysql','address'),port=int(base_config.get_value('mysql','port')),account=base_config.get_value('mysql','account'),password=base_config.get_value('mysql','password'))
......@@ -2,6 +2,7 @@ from TestData.automation.rule_test_data import ruleData
rule_select_sql = f'select * from `rule_define` where brand_id = {ruleData.brandId} and status != 3 and tpl_id = "{ruleData.rule_parent_template_id}" and child_rule = 0'
rule_select_result = ruleData.rule_db.select_many_value(sql=rule_select_sql)
if rule_select_result:
rule_num = len(rule_select_result)
......@@ -30,4 +31,8 @@ setattr(ruleData, 'select_rule_status', select_rule_status)
setattr(ruleData, 'select_rule_sort', select_rule_sort)
setattr(ruleData, 'select_rule_describe', select_rule_describe)
setattr(ruleData, 'rule_num_less', rule_num - 1)
if getattr(ruleData, 'create_rule_id'):
pass
else:
ruleData.create_rule_id = select_rule_id
ruleData.rule_db.close_db()
\ No newline at end of file
......@@ -5,7 +5,7 @@ all_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketStatu
your_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketStatusData.brandId} and `status` = 1 and `allocation_uid` = {ticketStatusData.userId} and `is_ignore` = 0 and room_type != 2'
unread_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketStatusData.brandId} and `status` = 1 and `read_status` = 1 and `is_ignore` = 0 and room_type != 2'
unassigned_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketStatusData.brandId} and `status` = 1 and `allocation_uid` = 0 and `is_ignore` = 0 and room_type != 2'
chatbot_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketStatusData.brandId} and `status` = 1 and `is_ignore` = 0 and room_type = 2'
chatbot_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketStatusData.brandId} and `status` = 1 and `is_ignore` = 0 and room_type in (2,3)'
all_ticket_num = len(test_env_conn.select_many_value(sql=all_ticket_select_sql))
......
......@@ -91,7 +91,8 @@ class ReqHandler:
data = case['data']
else:
data = {}
headers = {'Authorization' : getattr(global_variate.Global,'access_token'),'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'} #如果没有请求头,默认赋予一个带token的head
auth = getattr(global_variate.Global,'access_token') if 'c端' not in title else getattr(global_variate.Global,'customerToken')
headers = {'Authorization' : auth,'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'} #如果没有请求头,默认赋予一个带token的head
if case.get('headers'):
headers.update(case['headers'])
if method == 'post':
......@@ -128,8 +129,12 @@ class ReqHandler:
raise pymysql.err.InterfaceError
except urllib3.exceptions.MaxRetryError:
time.sleep(30) #超限时,暂停30秒
print('接口超限1')
self.send_requests(case,var_class)
except requests.exceptions.ConnectionError:
time.sleep(30) #超限时,暂停30秒
print('接口超限2')
self.send_requests(case,var_class)
except Exception as e:
import traceback
print(traceback.print_exc())
......
......@@ -9,7 +9,7 @@ class SqlHandler:
self.password = password
self.account = account
self.database = database
self.conn = pymysql.connect(host=address,port=port,user=account,password=password,database=database,cursorclass=pymysql.cursors.DictCursor,connect_timeout=60)
self.conn = pymysql.connect(host=address,port=port,user=account,password=password,database=database,cursorclass=pymysql.cursors.DictCursor,connect_timeout=60,read_timeout=120)
self.cursor = self.conn.cursor()
def select_one_value(self,sql):
......
......@@ -16,7 +16,7 @@ class ws:
self.attr = attr
async def get_client_id(self):
if not self.websocket:
self.websocket = await websockets.connect(self.url)
self.websocket = await websockets.connect(self.url,open_timeout=60)
enter_res = json.loads(await self.websocket.recv())
if enter_res.get('action'):
if enter_res['action'] in ['readMsg', 'tipmsg']:
......
api3:
api1:
title: 打开AI开关
url: api/v1/setting/local/updateShopSetting
method: post
......@@ -6,7 +6,7 @@ api3:
expected:
- eq: {"$.code": 0}
api4:
api2:
title: 检查AI开关状态
url: api/v1/setting/local/getShopSetting
method: post
......@@ -16,7 +16,7 @@ api4:
- eq: {"$.data.settingInfoMap.mapList['${shopId}'].[?(@.itemId == 202)].itemValue": '1'}
- eq: {"$.data.settingInfoMap.mapList['${shopId}'].[?(@.itemId == 203)].itemValue": '1'}
api5:
api3:
title: 检查产品接口
url: api/v1/shopify/local/productList
method: post
......@@ -30,7 +30,7 @@ api5:
- eq: {"$.data.list[?(@.productId == '${product_id}')].totalQuantity": '${product_quantity}'}
- eq: {"$.data.total": "${product_num}"}
api6:
api4:
title: 查询已学习的FAQ
url: api/v1/willai/local/getKbFaqs
method: post
......@@ -39,7 +39,7 @@ api6:
expected:
- eq: {"$.code": 0}
api7:
api5:
title: 查询已学习到的文档数量
url: api/v1/willai/local/docCount
method: post
......@@ -49,7 +49,7 @@ api7:
- eq: {"$.code": 0}
- exec: {"code": "assert res.json()['data']['faqCount'] == len(${faq_list})"}
api8:
api6:
title: 查询url接口
url: api/v1/willai/local/aiUrlList
method: post
......@@ -58,7 +58,7 @@ api8:
expected:
- eq: {"$.code": 0}
api9:
api7:
title: 新增url
url: api/v1/willai/local/addAiUrl
method: post
......@@ -66,7 +66,7 @@ api9:
expected:
- eq: {"$.code": 0}
api10:
api8:
title: 查询url接口
url: api/v1/willai/local/aiUrlList
method: post
......@@ -75,7 +75,7 @@ api10:
- eq: {"$.code": 0}
- exec: {"code": "assert res.json()['data']['total'] == str(int('${url_num}') + 1)"}
api11:
api9:
title: 编辑url
url: api/v1/willai/local/editAiUrl
method: post
......@@ -83,7 +83,7 @@ api11:
expected:
- eq: {"$.code": 0}
api12:
api10:
title: 查询url接口
url: api/v1/willai/local/aiUrlList
method: post
......@@ -92,7 +92,7 @@ api12:
- eq: {"$.code": 0}
- eq: {"$.data.list[?(@.id == '${url_id}')].url": "${edit_url}"}
api13:
api11:
title: 刷新url
url: api/v1/willai/local/reloadAiUrl
method: post
......@@ -100,7 +100,7 @@ api13:
expected:
- eq: {"$.code": 0}
api14:
api12:
title: 删除url
url: api/v1/willai/local/deleteAiUrl
method: post
......@@ -108,7 +108,7 @@ api14:
expected:
- eq: {"$.code": 0}
api15:
api13:
title: 查询url接口
url: api/v1/willai/local/aiUrlList
method: post
......@@ -118,7 +118,7 @@ api15:
- not_in_list: {"$.data.list[*].id": "${url_id}"}
- exec: {"code": "assert res.json()['data']['total'] == str(${url_num})"}
api16:
api14:
title: 查询QA接口
url: api/v1/willai/local/aiQAList
method: post
......@@ -127,7 +127,7 @@ api16:
expected:
- eq: {"$.code": 0}
api17:
api15:
title: 新增QA
url: api/v1/willai/local/addAiQa
method: post
......@@ -135,7 +135,7 @@ api17:
expected:
- eq: {"$.code": 0}
api18:
api16:
title: 查询QA接口
url: api/v1/willai/local/aiQAList
method: post
......@@ -145,7 +145,7 @@ api18:
- eq: {"$.code": 0}
- exec: {"code": "assert res.json()['data']['total'] == str(int('${qa_num}') + 1)"}
api19:
api17:
title: 编辑QA
url: api/v1/willai/local/modifyAiQa
method: post
......@@ -153,7 +153,7 @@ api19:
expected:
- eq: {"$.code": 0}
api20:
api18:
title: 查询QA接口
url: api/v1/willai/local/aiQAList
method: post
......@@ -163,7 +163,7 @@ api20:
- eq: {"$.data.list[?(@.id == '${qa_id}')].question": "${edit_question}"}
- eq: {"$.data.list[?(@.id == '${qa_id}')].answer": "${edit_answer}"}
api21:
api19:
title: 删除QA
url: api/v1/willai/local/deleteAiQa
method: post
......@@ -171,7 +171,7 @@ api21:
expected:
- eq: {"$.code": 0}
api22:
api20:
title: 查询QA接口
url: api/v1/willai/local/aiQAList
method: post
......@@ -180,7 +180,7 @@ api22:
- eq: {"$.code": 0}
- not_in_list: {"$.data.list[*].id": "${qa_id}"}
api23:
api21:
title: 编辑Email和推荐问题开关
url: api/v1/setting/local/updateShopSetting
method: post
......@@ -188,7 +188,7 @@ api23:
expected:
- eq: {"$.code": 0}
api24:
api22:
title: 检查Email和推荐问题开关是否编辑成功
url: api/v1/setting/local/getShopSetting
method: post
......@@ -198,7 +198,7 @@ api24:
- eq: {"$.data.settingInfoMap.mapList['${shopId}'].[?(@.itemId == 204)].itemValue": "${new_email}"}
- eq: {"$.data.settingInfoMap.mapList['${shopId}'].[?(@.itemId == 205)].itemValue": "0"}
api25:
api23:
title: 新增推荐问题
url: api/v1/willai/local/addAiQa
method: post
......@@ -206,7 +206,7 @@ api25:
expected:
- eq: {"$.code": 0}
api26:
api24:
title: 查看推荐问题列表
url: api/v1/willai/local/aiQAList
method: post
......@@ -216,7 +216,7 @@ api26:
- eq: {"$.code": 0}
- eq: {"$.data.list[?(@.question == '${new_suggest_question}')].answer": "${new_suggest_answer}"}
api27:
api25:
title: 编辑推荐问题
url: api/v1/willai/local/modifyAiQa
method: post
......@@ -224,7 +224,7 @@ api27:
expected:
- eq: {"$.code": 0}
api28:
api26:
title: 查看推荐问题列表
url: api/v1/willai/local/aiQAList
method: post
......@@ -234,7 +234,7 @@ api28:
- eq: {"$.data.list[?(@.id == '${suggest_qa_id}')].answer": "${edit_suggest_answer}"}
- eq: {"$.data.list[?(@.id == '${suggest_qa_id}')].question": "${edit_suggest_question}"}
api29:
api27:
title: 删除推荐问题
url: api/v1/willai/local/deleteAiQa
method: post
......@@ -242,7 +242,7 @@ api29:
expected:
- eq: {"$.code": 0}
api30:
api28:
title: 查看推荐问题列表
url: api/v1/willai/local/aiQAList
method: post
......@@ -251,7 +251,7 @@ api30:
- eq: {"$.code": 0}
- not_in_list: {"$.data.list[*].id": "${suggest_qa_id}"}
api31:
api29:
title: AI训练页面聊天
url: api/v1/willai/local/knowledgeTestChat
method: post
......@@ -259,7 +259,7 @@ api31:
expected:
- eq: {"$.code": 0}
api32:
api30:
title: 编辑Email和推荐问题开关
url: api/v1/setting/local/updateShopSetting
method: post
......@@ -267,7 +267,7 @@ api32:
expected:
- eq: {"$.code": 0}
api33:
api31:
title: 检查Email和推荐问题开关是否编辑成功
url: api/v1/setting/local/getShopSetting
method: post
......@@ -277,7 +277,7 @@ api33:
- eq: {"$.data.settingInfoMap.mapList['${shopId}'].[?(@.itemId == 204)].itemValue": ""}
- eq: {"$.data.settingInfoMap.mapList['${shopId}'].[?(@.itemId == 205)].itemValue": "1"}
api1:
api32:
title: 关闭AI开关
url: api/v1/setting/local/updateShopSetting
method: post
......@@ -285,7 +285,7 @@ api1:
expected:
- eq: {"$.code": 0}
api2:
api33:
title: 检查AI开关状态
url: api/v1/setting/local/getShopSetting
method: post
......
......@@ -76,23 +76,23 @@ api8:
expected:
- eq: {"$.code": 0}
api9:
title: 获取订单列表
url: /api/v1/order/local/getOrdersByCustomer
method: post
data: {"email":"${email}","shopId":"${shopId}","pageNum":1,"pageSize":20,"v":"${v}"}
before_sql: automation/orderflow/orderflow_order_select.py
expected:
- eq: {"$.code": 0}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].cancelReason": "${cancel_reason}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].userId": "${order_shop_id}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].trackingNumbers": "${tracking_number}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].totalAmount": "${total_amount}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].shipTo": "${ship_to}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].orderItems": "${order_items}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].financialStatus": "${financial_status}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].orderName": "${order_name}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].currency": "${currency}"}
- eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].orderId": "${order_id}"}
#api9:
# title: 获取订单列表
# url: /api/v1/order/local/getOrdersByCustomer
# method: post
# data: {"email":"${email}","shopId":"${shopId}","pageNum":1,"pageSize":20,"v":"${v}"}
# before_sql: automation/orderflow/orderflow_order_select.py
# expected:
# - eq: {"$.code": 0}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].cancelReason": "${cancel_reason}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].userId": "${order_shop_id}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].trackingNumbers": "${tracking_number}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].totalAmount": "${total_amount}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].shipTo": "${ship_to}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].orderItems": "${order_items}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].financialStatus": "${financial_status}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].orderName": "${order_name}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].currency": "${currency}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].orderId": "${order_id}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].cancelable": "${cancel_able}"}
# - eq: {"$.data.orderList[?(@.orderNumber == '${order_number}')].returnable": "${return_able}"}
......@@ -20,7 +20,7 @@ api3:
title: 恢复机器人信息
url: /api/v1/autoanswer/updateRobotInfo
method: post
data: {"brandId":"${brandId}","robotIcon":"${robot_origin_icon}","robotName":"${robot_origin_name}","v":"${v}"}
data: {"brandId":"${brandId}","robotIcon":"${robot_icon}","robotName":"${robot_origin_name}","v":"${v}"}
expected:
- eq: {"$.code":0}
......@@ -31,5 +31,5 @@ api4:
expected:
- eq: {"$.code":0}
- eq: {"$.data.robotName":"${robot_origin_name}"}
- eq: {"$.data.robotIcon":"${robot_origin_icon}"}
- eq: {"$.data.robotIcon":"${robot_icon}"}
- eq: {"$.data.brandId":"${brandId}"}
......@@ -18,7 +18,7 @@ api3:
url: /api/v1/businessPlan/buyBasicPlan
method: post
before_sql: billing/buyPlan_deleteNowPlan.py
data: {"shopId":"${shopId}","planId":"${FreePlanId}","v":"${v}"}
data: {"shopId":"${shopId}","planId":"${FreePlanId}","v":"${v}","openedAi": false}
expected:
- eq: {"$.code": 0}
......@@ -50,7 +50,7 @@ api6:
title: 购买付费套餐 - 检查是否返回shopify付款链接
url: /api/v1/businessPlan/buyBasicPlan
method: post
data: { "shopId": "${shopId}","planId": "${ProPlanId}","v": "${v}" }
data: { "shopId": "${shopId}","planId": "${ProPlanId}","v": "${v}","openedAi": false,"selectedItems":[{"itemId":1,"id":4044},{"itemId":2,"id":4062},{"itemId":6,"id":4323}]}
expected:
- eq: { "$.code": 0 }
- in: { "$.data.confirmationUrl" : "https://zhs-test.myshopify.com/admin/charges/4794771/"}
......
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