diff --git a/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py b/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py index 98b5baa83930d95f1d2a671a34c55100b33f7398..261a26c3ea79678eff5267a29f0752320af7b9c0 100644 --- a/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py +++ b/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py @@ -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' diff --git a/TestFile/setting/tag/tag_select2.py b/TestFile/setting/tag/tag_select2.py index 09a7d164c4300a38219ad62f165eee87b9044fca..081071d8cdadd32f2d7abae33b663cd2ade2a0eb 100644 --- a/TestFile/setting/tag/tag_select2.py +++ b/TestFile/setting/tag/tag_select2.py @@ -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'] diff --git a/Utils/req_handler.py b/Utils/req_handler.py index 09cfa2cea2a3b6ea396c143aea547ff00c2c7ee6..c329398ece2279fada6b1f46d7098120a411ca22 100644 --- a/Utils/req_handler.py +++ b/Utils/req_handler.py @@ -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()) diff --git a/YamlCase/billing/buyPlan.yaml b/YamlCase/billing/buyPlan.yaml index 69925b603cd1efe54677f3f6a4f592aa97351b05..8bceb31799a68f3739dff1f3f71dfa99cfce6e92 100644 --- a/YamlCase/billing/buyPlan.yaml +++ b/YamlCase/billing/buyPlan.yaml @@ -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: diff --git a/conftest.py b/conftest.py index 1ba4598caccedd1bb12bc24818da37c470969b6a..3929a410047c054ee9df471480f265c2649bc004 100644 --- a/conftest.py +++ b/conftest.py @@ -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()) #关闭服务