From ba67314a94d892002a3414fee0c3e330a9417276 Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Tue, 14 Jan 2025 14:59:28 +0800 Subject: [PATCH] bugfix --- TestFile/automation/ai/product_select_sql.py | 2 +- TestFile/inbox/ticketInfo_select.py | 12 +++++----- TestFile/inbox/ticketStatus_selectStatus.py | 8 +++---- ...opifyIntegration_integration_num_select.py | 23 +++++++++++-------- Utils/req_handler.py | 5 ++++ YamlCase/automation/ai.yaml | 13 ++--------- YamlCase/automation/rule.yaml | 2 ++ main.py | 2 +- 8 files changed, 35 insertions(+), 32 deletions(-) diff --git a/TestFile/automation/ai/product_select_sql.py b/TestFile/automation/ai/product_select_sql.py index 1f4ded3..675ac9d 100644 --- a/TestFile/automation/ai/product_select_sql.py +++ b/TestFile/automation/ai/product_select_sql.py @@ -1,6 +1,6 @@ from Utils.sql_handler import test_env_conn from TestData.automation.ai_test_data import AiTestData -product_select_sql = f'select * from `shopify_product` where shop_id = {AiTestData.shopId} and status = "active" and is_delete = 0 order by update_at desc' +product_select_sql = f'select * from `shopify_product` where shop_id = {AiTestData.shopId} and is_delete = 0 order by update_at desc' product_select_result = test_env_conn.select_many_value(sql=product_select_sql) diff --git a/TestFile/inbox/ticketInfo_select.py b/TestFile/inbox/ticketInfo_select.py index bfbc9b0..f0d1344 100644 --- a/TestFile/inbox/ticketInfo_select.py +++ b/TestFile/inbox/ticketInfo_select.py @@ -1,11 +1,11 @@ from TestData.inbox.ticketInfo_test_data import ticketInfoData -all_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 1 and `is_ignore` = 0 and room_type != 2' -wait_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 2 and `is_ignore` = 0 and room_type != 2' -close_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 3 and `is_ignore` = 0 and room_type != 2' -your_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 1 and `allocation_uid` = {ticketInfoData.userId} and `is_ignore` = 0 and room_type != 2' -your_wait_ticket_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 2 and `allocation_uid` = {ticketInfoData.userId} and `is_ignore` = 0 and room_type != 2' -your_close_ticket_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 3 and `allocation_uid` = {ticketInfoData.userId} and `is_ignore` = 0 and room_type != 2' +all_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 1 and `is_ignore` = 0 and (`room_type` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' +wait_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 2 and `is_ignore` = 0 and (`room_type` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' +close_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 3 and `is_ignore` = 0 and (`room_type` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' +your_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 1 and `allocation_uid` = {ticketInfoData.userId} and `is_ignore` = 0 and (`room_type` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' +your_wait_ticket_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 2 and `allocation_uid` = {ticketInfoData.userId} and `is_ignore` = 0 and (`room_type` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' +your_close_ticket_sql = f'select * from `im_room` where `cate_id` = {ticketInfoData.brandId} and `status` = 3 and `allocation_uid` = {ticketInfoData.userId} and `is_ignore` = 0 and (`room_type` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' all_ticket_num = len(ticketInfoData.ticket_info_db.select_many_value(sql=all_ticket_select_sql)) wait_ticket_num = len(ticketInfoData.ticket_info_db.select_many_value(sql=wait_ticket_select_sql)) diff --git a/TestFile/inbox/ticketStatus_selectStatus.py b/TestFile/inbox/ticketStatus_selectStatus.py index 0c8ff5e..39f8042 100644 --- a/TestFile/inbox/ticketStatus_selectStatus.py +++ b/TestFile/inbox/ticketStatus_selectStatus.py @@ -1,10 +1,10 @@ from Utils.sql_handler import test_env_conn from TestData.inbox.ticketStatus_test_data import ticketStatusData -all_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketStatusData.brandId} and `status` = 1 and `is_ignore` = 0 and room_type != 2' -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' +all_ticket_select_sql = f'select * from `im_room` where `cate_id` = {ticketStatusData.brandId} and `status` = 1 and `is_ignore` = 0 and (`room_type` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' +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` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' +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` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' +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` in (0,1) or (`room_type` = 3 and `ai_handle_status` = 100))' 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)' diff --git a/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py b/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py index 261a26c..f429d4f 100644 --- a/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py +++ b/TestFile/setting/shopifyIntegration/shopifyIntegration_integration_num_select.py @@ -19,20 +19,22 @@ macro_num = 0 whatsapp_id_list = () email_id_list = () facebook_id_list = () + +shop_select_sql = f'select * from `shop` where brand_id = {shopifyIntegrationData.brandId} and is_delete = 0 and `connect_status` = 2' +shop_select_result = test_env_conn.select_many_value(sql=shop_select_sql) +for shop in shop_select_result: + if shop['source'] == 1 : + js_shop_num += 1 + elif shop['source'] == 2 : + shopify_shop_num += 1 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' shop_select_result = test_env_conn.select_many_value(sql=shop_select_sql) for shop in shop_select_result: - if shop['source'] == 1 and shop['connect_status'] == 2: - js_shop_num += 1 - elif shop['source'] == 2 and shop['connect_status'] == 2: - shopify_shop_num += 1 - elif shop['source'] == 3: + if shop['source'] == 3: facebook_id_list += (shop['id'],) elif shop['source'] == 4: email_id_list += (shop['third_id'],) - elif shop['source'] == 5: - ins_shop_num += 1 elif shop['source'] == 6: whatsapp_id_list += (shop['third_id'],) @@ -57,12 +59,15 @@ if whatsapp_id_list: if facebook_id_list: timeStamp = time.time() 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)}' + facebook_select_sql = f'select * from im_facebook_channel_conf where site_id = {facebook_id_list[0]} and is_connected = 1 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_sql = f'select * from im_facebook_channel_conf where site_id in {facebook_id_list} and is_connected = 1 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) + for facebook in facebook_select_result: + if facebook['ins_relate'] is not None: + ins_shop_num += 1 setattr(shopifyIntegrationData, 'shopify_shop_num', shopify_shop_num) setattr(shopifyIntegrationData, 'js_shop_num', js_shop_num) diff --git a/Utils/req_handler.py b/Utils/req_handler.py index c329398..eae9820 100644 --- a/Utils/req_handler.py +++ b/Utils/req_handler.py @@ -154,6 +154,11 @@ class ReqHandler: time.sleep(10) # 超限时,暂停30秒 print('接口超限3') self.send_requests(case, var_class) + except pymysql.err.ProgrammingError: + from Utils import sql_handler + from Utils.config_handler import base_config + sql_handler.test_env_conn = 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')) + self.send_requests(case, var_class) except Exception as e: import traceback print(traceback.print_exc()) diff --git a/YamlCase/automation/ai.yaml b/YamlCase/automation/ai.yaml index 64e8276..dd0266b 100644 --- a/YamlCase/automation/ai.yaml +++ b/YamlCase/automation/ai.yaml @@ -76,15 +76,6 @@ api8: - exec: {"code": "assert res.json()['data']['total'] == str(int('${url_num}') + 1)"} -api10: - title: 查询url接口 - url: api/v1/willai/local/aiUrlList - method: post - data: {"page":1,"pageSize":100,"shopId":"${shopId}","v":"${v}","category": 1,"search": "","sortType": 0} - expected: - - eq: {"$.code": 0} - - eq: {"$.data.list[?(@.id == '${url_id}')].url": "${edit_url}"} - api11: title: 刷新url url: api/v1/willai/local/operateAiUrl @@ -95,7 +86,7 @@ api11: api12: title: 删除url - url: api/v1/willai/local/deleteAiUrl + url: api/v1/willai/local/operateAiUrl method: post data: {"shopId":"${shopId}","idList":["${url_id}"],"v":"${v}","selectAll": false,"status": 2,"excludeIdList": []} expected: @@ -236,7 +227,7 @@ api28: title: 查询in this knowledge的QA接口 url: api/v1/willai/local/aiQAList method: post - data: {"shopId":"${shopId}","page":1,"pageSize":15,"status":2,"search":"","lastDayType":2,"searchType":1,"timeZone":"Asia/Shanghai","v":"${v}"} + data: {"shopId":"${shopId}","page":1,"pageSize":15,"status":2,"search":"","lastDayType":4,"searchType":1,"timeZone":"Asia/Shanghai","v":"${v}"} expected: - eq: {"$.code": 0} - not_in_list: {"$.data.list[*].id": "${qa_id}"} diff --git a/YamlCase/automation/rule.yaml b/YamlCase/automation/rule.yaml index c6fc74e..df89279 100644 --- a/YamlCase/automation/rule.yaml +++ b/YamlCase/automation/rule.yaml @@ -53,6 +53,7 @@ api6: title: c端主动发起会话触发rule ws: customer action: sendmsg + sleep: 4 data: type: text @@ -77,6 +78,7 @@ api9: title: c端主动发起会话触发rule ws: customer action: sendmsg + sleep: 2 data: type: text diff --git a/main.py b/main.py index 16f44f8..beced1e 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ from Utils.sql_handler import test_env_conn if __name__ == '__main__': try: # pytest.main(['-vs',r'C:\Users\rd71\PycharmProjects\willdesk_api_auto\TestCase\inbox\test_06_channel.py',f'--alluredir=./allureReports/json','--clean-alluredir']) - pytest.main(['-vs','TestCase/billing',f'--html=./report.html']) #allure报告一直生成不了,改用pytest自带报告 + pytest.main(['-vs',f'--html=./report.html']) #allure报告一直生成不了,改用pytest自带报告 finally: test_env_conn.close_db() #关闭数据库链接 -- GitLab