From 31a75560596788e54516bfaa8ec2aab7f6e09ff1 Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Tue, 5 Nov 2024 17:47:27 +0800 Subject: [PATCH] bugfix --- TestData/inbox/search_test_data.py | 2 ++ .../setting/shopify_integration_test_data.py | 6 +++--- TestFile/inbox/search_order_select.py | 2 +- ...opifyIntegration_integration_num_select.py | 19 ++++++++++++++----- .../shopifyIntegration_shop_num_select.py | 2 +- Utils/sql_handler.py | 2 +- Utils/webhook_handler.py | 8 ++++---- YamlCase/FAQ/article_opreate.yaml | 14 +++----------- YamlCase/automation/ai.yaml | 3 ++- YamlCase/automation/template.yaml | 8 ++++---- YamlCase/setting/team.yaml | 4 ++-- 11 files changed, 37 insertions(+), 33 deletions(-) diff --git a/TestData/inbox/search_test_data.py b/TestData/inbox/search_test_data.py index 7c74db9..531aca3 100644 --- a/TestData/inbox/search_test_data.py +++ b/TestData/inbox/search_test_data.py @@ -4,3 +4,5 @@ class searchtData(Global): insert_room_chat_record = 'autotestRoomChatRecord' insert_room_title = 'autotestRoomTitle' insert_record_json = {"contentList":"%s"%insert_room_chat_record,"attachmentList":[]} + shopId = 7238 + brandId = 6052 \ No newline at end of file diff --git a/TestData/setting/shopify_integration_test_data.py b/TestData/setting/shopify_integration_test_data.py index bd8c146..6d803ef 100644 --- a/TestData/setting/shopify_integration_test_data.py +++ b/TestData/setting/shopify_integration_test_data.py @@ -1,11 +1,11 @@ from Utils.global_variate import Global - +from Utils.mockData_handler import data_handler class shopifyIntegrationData(Global): brandId = 6052 companyId = 6059 append_shop_name = 'autotest' update_shop_name = 'update_autotest_shop_name' - append_shop_url = 'autotest.shopify.com' + append_shop_url = 'autotest%s.shopify.com'%data_handler.random_id() append_third_id = '510588288139012978' append_shop_js = '' append_faq_willdesk_domain = 'cojnpvo6nc921eeo4fc0.willdesk.net' @@ -16,7 +16,7 @@ class shopifyIntegrationData(Global): append_shop_connect_status = 1 shop_source = 2 append_js_shop_name = 'autotest_js_shop' - append_js_shop_url = 'autotest_js_shop.shopify.com' + append_js_shop_url = 'autotest_js%s.shopify.com'%data_handler.random_id() js_soucrce = 1 active_shop_email = 'zhanhuasheng@channelwill.cn' new_workspance_name = 'autotest_workspace' diff --git a/TestFile/inbox/search_order_select.py b/TestFile/inbox/search_order_select.py index 0d22332..0fdb97c 100644 --- a/TestFile/inbox/search_order_select.py +++ b/TestFile/inbox/search_order_select.py @@ -7,7 +7,7 @@ email_list = tuple([order['email'] for order in user_order_select_result]) user_select_sql = f'select * from `customer` where brand_id = {searchtData.brandId} and email in {email_list}' user_select_result = test_env_conn.select_many_value(sql=user_select_sql) user_list = tuple([user['id'] for user in user_select_result]) -room_select_sql = f'select * from `im_room` where from_id in {user_list} and cate_id = {searchtData.brandId} and status = 1 and room_type != 2 and is_ignore = 0 and site_id = {searchtData.shopId} ' +room_select_sql = f'select * from `im_room` where from_id in {user_list} and cate_id = {searchtData.brandId} and status = 1 and room_type != 2 and is_ignore = 0 ' room_select_result = test_env_conn.select_one_value(sql=room_select_sql) room_id = room_select_result['room_id'] user_id = room_select_result['from_id'] diff --git a/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py b/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py index 6298f1f..98b5baa 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' @@ -37,20 +37,29 @@ if shop_id_list: whatsapp_id_list += (shop['third_id'],) if email_id_list: - email_select_sql = f'select * from `email_config` where id in {email_id_list} and connect_status = 0' + if len(email_id_list) == 1: + email_select_sql = f'select * from `email_config` where id = {email_id_list[0]} and connect_status = 0' + else: + email_select_sql = f'select * from `email_config` where id in {email_id_list} and connect_status = 0' email_select_result = test_env_conn.select_many_value(sql=email_select_sql) if email_select_result: email_shop_num = len(email_select_result) if whatsapp_id_list: - whatsapp_select_sql = f'select * from `whatsapp_phone` where waba_id in {whatsapp_id_list} and status = "CONNECTED" and brand_id = {shopifyIntegrationData.brandId}' + if len(whatsapp_id_list) == 1: + whatsapp_select_sql = f'select * from `whatsapp_phone` where waba_id = {whatsapp_id_list[0]} and status = "CONNECTED" and brand_id = {shopifyIntegrationData.brandId}' + else: + whatsapp_select_sql = f'select * from `whatsapp_phone` where waba_id in {whatsapp_id_list} and status = "CONNECTED" and brand_id = {shopifyIntegrationData.brandId}' whatsapp_select_result = test_env_conn.select_many_value(sql=whatsapp_select_sql) if whatsapp_select_result: whatsapp_shop_num = len(whatsapp_select_result) if facebook_id_list: timeStamp = time.time() - facebook_select_sql = f'select * from im_facebook_channel_conf where site_id in {facebook_id_list} and is_connected = 1 and ins_relate = "" and expires_at > {int(timeStamp)}' + if len(facebook_id_list) == 1: + facebook_select_sql = f'select * from im_facebook_channel_conf where site_id = {facebook_id_list[0]} and is_connected = 1 and ins_relate = "" and expires_at > {int(timeStamp)}' + else: + facebook_select_sql = f'select * from im_facebook_channel_conf where site_id in {facebook_id_list} and is_connected = 1 and ins_relate = "" and expires_at > {int(timeStamp)}' facebook_select_result = test_env_conn.select_many_value(sql=facebook_select_sql) if facebook_select_result: facebook_shop_num = len(facebook_select_result) @@ -67,4 +76,4 @@ macro_select_result = test_env_conn.select_many_value(sql=macro_select_sql) if macro_select_result: macro_num = len(macro_select_result) -setattr(shopifyIntegrationData, 'macro_num', macro_num) \ No newline at end of file +setattr(shopifyIntegrationData, 'macro_num', macro_num) diff --git a/TestFile/setting/shopifyIntegration/shopifyIntegration_shop_num_select.py b/TestFile/setting/shopifyIntegration/shopifyIntegration_shop_num_select.py index 025932a..e3011db 100644 --- a/TestFile/setting/shopifyIntegration/shopifyIntegration_shop_num_select.py +++ b/TestFile/setting/shopifyIntegration/shopifyIntegration_shop_num_select.py @@ -3,4 +3,4 @@ from TestData.setting.shopify_integration_test_data import shopifyIntegrationDat shopify_shop_select_sql = f'select * from `shop` where brand_id = {shopifyIntegrationData.brandId} and source in (1,2) and is_delete in (0,2)' shopify_shop_select_result = test_env_conn.select_many_value(shopify_shop_select_sql) shopify_shop_num = len(shopify_shop_select_result) -setattr(shopifyIntegrationData, 'shop_num', shopify_shop_num) \ No newline at end of file +setattr(shopifyIntegrationData, 'shop_num', shopify_shop_num) diff --git a/Utils/sql_handler.py b/Utils/sql_handler.py index 283b163..be1ef8f 100644 --- a/Utils/sql_handler.py +++ b/Utils/sql_handler.py @@ -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,read_timeout=120) + self.conn = pymysql.connect(host=address,port=port,user=account,password=password,database=database,cursorclass=pymysql.cursors.DictCursor) self.cursor = self.conn.cursor() def select_one_value(self,sql): diff --git a/Utils/webhook_handler.py b/Utils/webhook_handler.py index 4742faf..f2fa96b 100644 --- a/Utils/webhook_handler.py +++ b/Utils/webhook_handler.py @@ -8,16 +8,16 @@ import urllib.parse timestamp = str(round(time.time() * 1000)) -secret = 'SEC7c41f8b0298b348ed538883c49068185b75c510d64dcb988fc570cb7614f07ff' #正式的webhook -# secret = 'SEC9d91939234e83369cba32c0ca4bcd9af60b5b1f69424d6fabd36f48d572a151c' #测试用的webhook +# secret = 'SEC7c41f8b0298b348ed538883c49068185b75c510d64dcb988fc570cb7614f07ff' #正式的webhook +secret = 'SEC9d91939234e83369cba32c0ca4bcd9af60b5b1f69424d6fabd36f48d572a151c' #测试用的webhook secret_enc = secret.encode('utf-8') string_to_sign = '{}\n{}'.format(timestamp, secret) string_to_sign_enc = string_to_sign.encode('utf-8') hmac_code = hmac.new(secret_enc, string_to_sign_enc, digestmod=hashlib.sha256).digest() sign = urllib.parse.quote_plus(base64.b64encode(hmac_code)) -# webhook_url = 'https://oapi.dingtalk.com/robot/send?access_token=22fda27990b00841c3201c20649c0a8abb6da82d8472b6f6154ef4cd9dadb33f' #测试用的webhook -webhook_url = 'https://oapi.dingtalk.com/robot/send?access_token=c7d3c3a67db4cf7b3472e62005a25ce202daac8095f32530687afdb91f1616b6' #正式的webhook +webhook_url = 'https://oapi.dingtalk.com/robot/send?access_token=22fda27990b00841c3201c20649c0a8abb6da82d8472b6f6154ef4cd9dadb33f' #测试用的webhook +# webhook_url = 'https://oapi.dingtalk.com/robot/send?access_token=c7d3c3a67db4cf7b3472e62005a25ce202daac8095f32530687afdb91f1616b6' #正式的webhook class webhookHandler: def __init__(self,webhookUrl = f"{webhook_url}×tamp={timestamp}&sign={sign}"): diff --git a/YamlCase/FAQ/article_opreate.yaml b/YamlCase/FAQ/article_opreate.yaml index 45aaebb..d85455d 100644 --- a/YamlCase/FAQ/article_opreate.yaml +++ b/YamlCase/FAQ/article_opreate.yaml @@ -31,14 +31,6 @@ api3: - eq: {"$.data.articleList[?(@.id==${article_id})].isPublish": "${article_is_publish}" } - eq: {"$.data.articleList[?(@.id==${article_id})].isPopular": "${article_is_popular}" } -api4: - title: 更新文章seo - url: /api/v1/faq/updateArticleMeta - method: post - data: {"id":"${article_id}","metaTitle":"${article_seo_title}","metaDescription":"${article_seo_description}","v":"${v}"} - expected: - - eq: {"$.code": 0} - api5: title: 新增文章 - 2 url: /api/v1/faq/addArticle @@ -60,7 +52,7 @@ api7: title: 更新文章内容 url: /api/v1/faq/updateArticle method: post - data: {"shopId":"${shopId}","id":"${article_id}","articleCategoryId":"${category_id}","title":"${article_new_name}","content":"${article_new_content}","articleKeywords":"${article_new_keyword}","isPublish":"${article_new_is_publish}","isPopular":"${article_new_is_popular}","articleSort":1,"v":"${v}"} + data: {"shopId":"${shopId}","id":"${article_id}","articleCategoryId":"${category_id}","title":"${article_new_name}","content":"${article_new_content}","articleKeywords":"${article_new_keyword}","isPublish":"${article_new_is_publish}","isPopular":"${article_new_is_popular}","articleSort":1,"v":"${v}","metaDescription":"${article_seo_description}","metaTitle":"${article_seo_title}"} expected: - eq: {"$.code": 0} @@ -98,9 +90,9 @@ api10: api11: title: 删除分类 - url: /api/v1/faq/deleteCategory + url: /api/v1/helpcenter/deleteCategory method: post - data: {"id":"${category_id}","v":"${v}"} + data: {"catId":"${category_id}","newCatId":0,"v":"${v}"} expected: - eq: {"$.code": 0} diff --git a/YamlCase/automation/ai.yaml b/YamlCase/automation/ai.yaml index e6eac21..95a4db2 100644 --- a/YamlCase/automation/ai.yaml +++ b/YamlCase/automation/ai.yaml @@ -202,7 +202,8 @@ api23: title: 新增推荐问题 url: api/v1/willai/local/addAiQa method: post - data: {"category":1,"shopId":"${shopId}","question":"${new_suggest_question}","answer":"${new_suggest_answer}","v":"${v}"} + data: {"category":2,"shopId":"${shopId}","question":"${new_suggest_question}","answer":"${new_suggest_answer}","v":"${v}"} + sleep: 3 expected: - eq: {"$.code": 0} diff --git a/YamlCase/automation/template.yaml b/YamlCase/automation/template.yaml index d912fbb..9e91e23 100644 --- a/YamlCase/automation/template.yaml +++ b/YamlCase/automation/template.yaml @@ -7,9 +7,9 @@ api1: expected: - eq: {"$.code":0} - eq: {"$.data.total": "${workflow_template_num}"} - - eq: {"$.data.list[?(@.tpldId == '${workflow_template_id}')].describe": "${workflow_template_describe}"} +# - eq: {"$.data.list[?(@.tpldId == '${workflow_template_id}')].describe": "${workflow_template_describe}"} - eq: {"$.data.list[?(@.tpldId == '${workflow_template_id}')].eventId": "${workflow_template_event_id}"} - - eq: {"$.data.list[?(@.tpldId == '${workflow_template_id}')].title": "${workflow_template_title}"} +# - eq: {"$.data.list[?(@.tpldId == '${workflow_template_id}')].title": "${workflow_template_title}"} api2: title: 检查rule模板列表 @@ -19,6 +19,6 @@ api2: expected: - eq: {"$.code":0} - eq: {"$.data.total": "${rule_template_num}"} - - eq: {"$.data.list[?(@.tpldId == '${rule_template_id}')].describe": "${rule_template_describe}"} +# - eq: {"$.data.list[?(@.tpldId == '${rule_template_id}')].describe": "${rule_template_describe}"} - eq: {"$.data.list[?(@.tpldId == '${rule_template_id}')].eventId": "${rule_template_event_id}"} - - eq: {"$.data.list[?(@.tpldId == '${rule_template_id}')].title": "${rule_template_title}"} \ No newline at end of file +# - eq: {"$.data.list[?(@.tpldId == '${rule_template_id}')].title": "${rule_template_title}"} \ No newline at end of file diff --git a/YamlCase/setting/team.yaml b/YamlCase/setting/team.yaml index da05fd9..d77f779 100644 --- a/YamlCase/setting/team.yaml +++ b/YamlCase/setting/team.yaml @@ -2,7 +2,7 @@ api1: title: 新建一个队友 url: /api/v1/customerService/customerServiceSendInvitation method: post - data: {"email":"${teammate_email}","role":"${teammate_role}","brand":"${brandName}","hasAllConversation":false,"resourceItemIds":[],"v":"${v}"} + data: {"email":"${teammate_email}","role":"${teammate_role}","brand":"${brandName}","hasAllConversation":true,"resourceItemIds":[],"v":"${v}"} expected: - eq: {"$.code": 0} @@ -16,7 +16,7 @@ api2: - eq: {"$.code": 0} - in_list: {"$.data.list[*].id": "${teammate_id}"} - eq: {"$.data.list[?(@.id=='${teammate_id}')].email":"${teammate_email}"} - - eq: {"$.data.list[?(@.id=='${teammate_id}')].hasAllConversation": False} + - eq: {"$.data.list[?(@.id=='${teammate_id}')].hasAllConversation": True} - eq: {"$.data.list[?(@.id=='${teammate_id}')].role":"${teammate_role}"} # - exec: {"code": "assert len(res.json()['data']['list']) == ${teammate_num} + 1"} -- GitLab