Commit 49fe1438 authored by zhanhuasheng's avatar zhanhuasheng

bugfix

parent 31a75560
......@@ -17,7 +17,7 @@ ins_shop_num = 0
macro_num = 0
whatsapp_id_list = ()
email_id_list = []
email_id_list = ()
facebook_id_list = ()
if shop_id_list:
shop_select_sql = f'select * from `shop` where id in {shop_id_list} and brand_id = {shopifyIntegrationData.brandId} and is_delete = 0'
......
......@@ -17,7 +17,7 @@ else:
page_num = int(tag_location / 10) + 1
setattr(tagData, 'page_num', int(page_num))
tag_room_select_sql = f'select * from `im_room` where `cate_id` = {tagData.brandId} and `status` = 1 and `site_id` = {tagData.shopId} and `is_ignore` = 0 and room_type != 2 and last_msg_uid != {tagData.userId} and from_id != ""'
tag_room_select_sql = f'select * from `im_room` where `cate_id` = {tagData.brandId} and status = 1 and `site_id` = {tagData.shopId} and `is_ignore` = 0 and room_type != 2 '
tag_room_select_result = tagData.new_db_coon.select_one_value(sql=tag_room_select_sql)
room_id = tag_room_select_result['room_id']
user_id = tag_room_select_result['from_id']
......
......@@ -18,7 +18,7 @@ from Utils.log_handler import logger
class ReqHandler:
def params_handler(self,case,var_class):
def params_handler(self,case,var_class,needReplace=False):
'''
用来处理替换${}变量的方法
:param case: 传入需要替换变量的用例字典
......@@ -26,6 +26,10 @@ class ReqHandler:
:return: 返回处理好的case字典
'''
try:
if case.get('replace'):
needReplace = True
wordList = case['replace']
newWordList = []
case = str(case)
replace_words = re.findall(r'\$\{(.+?)\}',case)
if not replace_words:
......@@ -40,12 +44,23 @@ class ReqHandler:
case = case.replace(r"${%s}"%word,str(value)) #替换掉${}变量符
if re.findall(r'\$\{(.+?)\}',case): #保底
case = case.replace(r'${%s}'%word,str(value))
if needReplace:
for word in wordList:
case = case.replace(value,'')
newWordList.append({word:f'''{value}'''})
except Exception:
import traceback
print(traceback.print_exc())
print(f'{word}变量未找到')
raise Exception
return eval(case)
if needReplace:
case = eval(case)
for newWord in newWordList:
for key,value in newWord.items():
case['data'][key] = value
return case
else:
return eval(case)
except SyntaxError:
print('内容可能含有单引号或者换行导致报错,用例:',case)
raise Exception
......@@ -135,6 +150,10 @@ class ReqHandler:
time.sleep(30) #超限时,暂停30秒
print('接口超限2')
self.send_requests(case,var_class)
except requests.exceptions.SSLError:
time.sleep(10) # 超限时,暂停30秒
print('接口超限3')
self.send_requests(case, var_class)
except Exception as e:
import traceback
print(traceback.print_exc())
......
......@@ -17,7 +17,7 @@ api3:
title: 订阅免费套餐
url: /api/v1/businessPlan/buyBasicPlan
method: post
before_sql: billing/buyPlan_deleteNowPlan.py
# before_sql: billing/buyPlan_deleteNowPlan.py
data: {"shopId":"${shopId}","planId":"${FreePlanId}","v":"${v}","openedAi": false}
expected:
- eq: {"$.code": 0}
......@@ -55,19 +55,28 @@ api6:
- eq: { "$.code": 0 }
- in: { "$.data.confirmationUrl" : "https://zhs-test.myshopify.com/admin/charges/4794771/"}
api6-1:
title: 通过后台切换成付费套餐
url: https://backstage.willdesk.com/api/v1/BackStage/Plans/changeUserPlan
method: post
headers: {'Authorization': "${backstage_token}"}
data: {"id":24042,"compId":"${companyId}","shopName":"${name}","shopDomain":"${shopDomain}","planName":"'${ProPlanId}'","expireAt":"${next_month}","batchCode":"1853733781630881792"}
expected:
- eq: {"$.code": 0}
api7:
title: 检查是否切为付费套餐(仅校验了额度,没有校验planid)
url: /api/v1/businessPlan/getCompanyCurrentPlan?v=${v}
method: get
before_sql: billing/buyPlan_updateToPro.py
# before_sql: billing/buyPlan_updateToPro.py
expected:
- eq: { "$.code": 0 }
# - eq: { "$.data.planId": "${ProPlanId}" }
- eq: { "$.data.companyBasicPlanItem[?(@.itemId == 1)].amount": 2000 }
- eq: { "$.data.companyBasicPlanItem[?(@.itemId == 2)].amount": 2000 }
- eq: { "$.data.companyBasicPlanItem[?(@.itemId == 10)].amount": 2000 }
- eq: { "$.data.companyBasicPlanItem[?(@.itemId == 3)].amount": -1 }
- eq: { "$.data.createAtFormat": "${today}" }
- eq: { "$.data.planId": "${ProPlanId}" }
# - eq: { "$.data.companyBasicPlanItem[?(@.itemId == 1)].amount": 2000 }
# - eq: { "$.data.companyBasicPlanItem[?(@.itemId == 2)].amount": 2000 }
# - eq: { "$.data.companyBasicPlanItem[?(@.itemId == 10)].amount": 2000 }
# - eq: { "$.data.companyBasicPlanItem[?(@.itemId == 3)].amount": -1 }
# - eq: { "$.data.createAtFormat": "${today}" }
- eq: { "$.data.expireAtFormat": "${next_month}" }
api8:
......
......@@ -10,6 +10,12 @@ from _pytest import terminal
from Utils import webhook_handler
session = requests.session()
def backstage_login():
url = 'https://backstage.willdesk.com/api/v1/BackStage/AdminUser/login'
data = {"password":"123456","username":"willdesk"}
res = requests.post(url=url,json=data)
token = res.json()['data']['token']
setattr(global_variate.Global,'backstage_token',token)
def willdesk_login():
'''
执行用例前获取登录态的接口,全局只执行一次,通过env参数控制是否测试环境
......@@ -127,6 +133,7 @@ def call_fixture():
#自定义调用顺序
willdesk_login()
customer_login()
backstage_login()
loop.run_until_complete(get_client_id()) #初始化获取clientid
yield
loop.run_until_complete(close_ws()) #关闭服务
......
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