From ad82365b6761952ea4f922c8948a0458bd2dc9e1 Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Mon, 22 Apr 2024 18:42:12 +0800 Subject: [PATCH] bugfix --- TestCase/FAQ/test_01_article_info.py | 1 - TestCase/FAQ/test_02_article_opreate.py | 1 - TestCase/FAQ/test_03_article_page_setting.py | 1 - TestCase/account/test_01_account.py | 1 - TestCase/billing/test_01_buyPlan.py | 1 - TestCase/customer/test_01_customer.py | 1 - TestCase/inbox/test_01_livechat.py | 1 - TestCase/inbox/test_02_ticketStatus.py | 1 - TestCase/inbox/test_03_ticketOpreate.py | 1 - TestCase/inbox/test_04_ticketInfo.py | 1 - TestCase/inbox/test_05_team.py | 1 - TestCase/inbox/test_06_channel.py | 1 - TestCase/inbox/test_07_ticketDetail.py | 1 - TestCase/report/test_01_report.py | 1 - TestCase/setting/test_01_emailIntegration.py | 1 - TestCase/setting/test_02_whatsappIntegration.py | 1 - TestCase/setting/test_04_widgetSetting.py | 1 - TestData/setting/email_integration_test_data.py | 3 ++- Utils/req_handler.py | 2 ++ Utils/webhook_handler.py | 10 +++++----- 20 files changed, 9 insertions(+), 23 deletions(-) diff --git a/TestCase/FAQ/test_01_article_info.py b/TestCase/FAQ/test_01_article_info.py index 95153c0..87e6f1b 100644 --- a/TestCase/FAQ/test_01_article_info.py +++ b/TestCase/FAQ/test_01_article_info.py @@ -11,4 +11,3 @@ class TestFAQ: @pytest.mark.parametrize('case',yaml_data) def test_article(self,case): req_handler.ReqHandler.send_requests(case=case,var_class=articleInfoTestData) - print(case) \ No newline at end of file diff --git a/TestCase/FAQ/test_02_article_opreate.py b/TestCase/FAQ/test_02_article_opreate.py index ceb195a..1ac7496 100644 --- a/TestCase/FAQ/test_02_article_opreate.py +++ b/TestCase/FAQ/test_02_article_opreate.py @@ -11,4 +11,3 @@ class TestArticleOpreate: @pytest.mark.parametrize('case',yaml_data) def test_article_opreate(self,case): req_handler.ReqHandler.send_requests(case=case,var_class=articleOperateTestData) - print(case) \ No newline at end of file diff --git a/TestCase/FAQ/test_03_article_page_setting.py b/TestCase/FAQ/test_03_article_page_setting.py index a4948b6..90724f2 100644 --- a/TestCase/FAQ/test_03_article_page_setting.py +++ b/TestCase/FAQ/test_03_article_page_setting.py @@ -11,4 +11,3 @@ class TestArticleOpreate: @pytest.mark.parametrize('case',yaml_data) def test_article_page_setting(self,case): req_handler.ReqHandler.send_requests(case=case,var_class=articlePageSettingTestData) - print(case) \ No newline at end of file diff --git a/TestCase/account/test_01_account.py b/TestCase/account/test_01_account.py index 98d9db7..0a0757f 100644 --- a/TestCase/account/test_01_account.py +++ b/TestCase/account/test_01_account.py @@ -12,4 +12,3 @@ class TestAccount: @pytest.mark.parametrize('case',yaml_data) def test_account(self,case): req_handler.ReqHandler.send_requests(case=case,var_class=accountData) - print(case) \ No newline at end of file diff --git a/TestCase/billing/test_01_buyPlan.py b/TestCase/billing/test_01_buyPlan.py index ac2ecd9..6b024be 100644 --- a/TestCase/billing/test_01_buyPlan.py +++ b/TestCase/billing/test_01_buyPlan.py @@ -11,4 +11,3 @@ class TestBuyPlan: @pytest.mark.parametrize('case',yaml_data) def test_buy_plan(self,case): req_handler.ReqHandler.send_requests(case=case,var_class=buyPlanData) - print(case) \ No newline at end of file diff --git a/TestCase/customer/test_01_customer.py b/TestCase/customer/test_01_customer.py index 0c65666..7489cd2 100644 --- a/TestCase/customer/test_01_customer.py +++ b/TestCase/customer/test_01_customer.py @@ -11,4 +11,3 @@ class TestCustomer: @pytest.mark.parametrize('case',yaml_data) def test_customer(self,case): req_handler.ReqHandler.send_requests(case=case,var_class=customerData) - print(case) \ No newline at end of file diff --git a/TestCase/inbox/test_01_livechat.py b/TestCase/inbox/test_01_livechat.py index 59a4167..06400ff 100644 --- a/TestCase/inbox/test_01_livechat.py +++ b/TestCase/inbox/test_01_livechat.py @@ -11,4 +11,3 @@ class TestLivechat: @pytest.mark.parametrize('case',yaml_data) def test_livechat(self,case): req_handler.ReqHandler.send_requests(case=case,var_class=livechatData) - print(case) \ No newline at end of file diff --git a/TestCase/inbox/test_02_ticketStatus.py b/TestCase/inbox/test_02_ticketStatus.py index f04b46a..7410a90 100644 --- a/TestCase/inbox/test_02_ticketStatus.py +++ b/TestCase/inbox/test_02_ticketStatus.py @@ -10,5 +10,4 @@ class TestTicketStatus: @pytest.mark.flaky(reruns=ticketStatusData.rerun, reruns_delay=ticketStatusData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_ticketStatus(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=ticketStatusData) diff --git a/TestCase/inbox/test_03_ticketOpreate.py b/TestCase/inbox/test_03_ticketOpreate.py index 38c7c2a..794cff2 100644 --- a/TestCase/inbox/test_03_ticketOpreate.py +++ b/TestCase/inbox/test_03_ticketOpreate.py @@ -14,5 +14,4 @@ class TestTicketOpreate: @pytest.mark.flaky(reruns=ticketStatusData.rerun, reruns_delay=ticketStatusData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_ticketOpreate(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=ticketStatusData) diff --git a/TestCase/inbox/test_04_ticketInfo.py b/TestCase/inbox/test_04_ticketInfo.py index d69327d..0ef3ac0 100644 --- a/TestCase/inbox/test_04_ticketInfo.py +++ b/TestCase/inbox/test_04_ticketInfo.py @@ -10,5 +10,4 @@ class TestTicketInfo: @pytest.mark.flaky(reruns=ticketInfoData.rerun, reruns_delay=ticketInfoData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_ticketInfo(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=ticketInfoData) diff --git a/TestCase/inbox/test_05_team.py b/TestCase/inbox/test_05_team.py index f75d69c..1615f4c 100644 --- a/TestCase/inbox/test_05_team.py +++ b/TestCase/inbox/test_05_team.py @@ -10,5 +10,4 @@ class TestTeam: @pytest.mark.flaky(reruns=teamData.rerun, reruns_delay=teamData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_team(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=teamData) diff --git a/TestCase/inbox/test_06_channel.py b/TestCase/inbox/test_06_channel.py index 0f7804e..50907dd 100644 --- a/TestCase/inbox/test_06_channel.py +++ b/TestCase/inbox/test_06_channel.py @@ -10,5 +10,4 @@ class TestChannel: @pytest.mark.flaky(reruns=channelData.rerun, reruns_delay=channelData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_channel(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=channelData) diff --git a/TestCase/inbox/test_07_ticketDetail.py b/TestCase/inbox/test_07_ticketDetail.py index 862127f..93102af 100644 --- a/TestCase/inbox/test_07_ticketDetail.py +++ b/TestCase/inbox/test_07_ticketDetail.py @@ -10,5 +10,4 @@ class TestTiocketDetail: @pytest.mark.flaky(reruns=ticketDetailData.rerun, reruns_delay=ticketDetailData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_ticketDetail(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=ticketDetailData) diff --git a/TestCase/report/test_01_report.py b/TestCase/report/test_01_report.py index fd264d5..4d176ba 100644 --- a/TestCase/report/test_01_report.py +++ b/TestCase/report/test_01_report.py @@ -11,4 +11,3 @@ class TestReport: @pytest.mark.parametrize('case',yaml_data) def test_report(self,case): req_handler.ReqHandler.send_requests(case=case,var_class=reportData) - print(case) \ No newline at end of file diff --git a/TestCase/setting/test_01_emailIntegration.py b/TestCase/setting/test_01_emailIntegration.py index 63c914b..6c2fc9a 100644 --- a/TestCase/setting/test_01_emailIntegration.py +++ b/TestCase/setting/test_01_emailIntegration.py @@ -11,5 +11,4 @@ class TestEmailIntegration: @pytest.mark.flaky(reruns=emailIntegrationData.rerun, reruns_delay=emailIntegrationData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_emailIntegration(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=emailIntegrationData) diff --git a/TestCase/setting/test_02_whatsappIntegration.py b/TestCase/setting/test_02_whatsappIntegration.py index 1a9ce5e..7796554 100644 --- a/TestCase/setting/test_02_whatsappIntegration.py +++ b/TestCase/setting/test_02_whatsappIntegration.py @@ -10,5 +10,4 @@ class TestWhatsappIntegration: @pytest.mark.flaky(reruns=whatsappIntegrationData.rerun, reruns_delay=whatsappIntegrationData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_whatsappIntegration(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=whatsappIntegrationData) diff --git a/TestCase/setting/test_04_widgetSetting.py b/TestCase/setting/test_04_widgetSetting.py index ff50d85..76c8757 100644 --- a/TestCase/setting/test_04_widgetSetting.py +++ b/TestCase/setting/test_04_widgetSetting.py @@ -10,5 +10,4 @@ class TestWidgetSetting: @pytest.mark.flaky(reruns=widgetSettingData.rerun, reruns_delay=widgetSettingData.rerun_delay) @pytest.mark.parametrize('case',yaml_data) def test_widgetSetting(self,case): - print(case) req_handler.ReqHandler.send_requests(case=case,var_class=widgetSettingData) diff --git a/TestData/setting/email_integration_test_data.py b/TestData/setting/email_integration_test_data.py index e4bf3e7..0725b7e 100644 --- a/TestData/setting/email_integration_test_data.py +++ b/TestData/setting/email_integration_test_data.py @@ -1,7 +1,8 @@ from Utils.global_variate import Global +from Utils.mockData_handler import data_handler class emailIntegrationData(Global): - append_email_address = 'autotest@channelwill.cn' + append_email_address = f'{data_handler.name()}@channelwill.cn' append_email_name = 'autotest' append_email_status = 0 new_email_name = 'autotest2' diff --git a/Utils/req_handler.py b/Utils/req_handler.py index ac37046..f7a2949 100644 --- a/Utils/req_handler.py +++ b/Utils/req_handler.py @@ -104,11 +104,13 @@ class ReqHandler: raise TypeError('用例格式有误') except AssertionError: logger.error(f'{title}用例执行失败,失败原因:断言不通过\n用例{case}\n期望值{expected}\n实际返回值{res.text}') + print(f'{title}用例执行失败,失败原因:断言不通过\n用例{case}\n期望值{expected}\n实际返回值{res.text}') raise AssertionError except Exception as e: import traceback print(traceback.print_exc()) logger.error(f'{title}用例执行失败,失败原因:{e}') + print(f'{title}用例执行失败,失败原因:{e}\n用例{case}') raise Exception def ws_requests(self,case): diff --git a/Utils/webhook_handler.py b/Utils/webhook_handler.py index 38272fa..e426095 100644 --- a/Utils/webhook_handler.py +++ b/Utils/webhook_handler.py @@ -9,18 +9,19 @@ import urllib.parse timestamp = str(round(time.time() * 1000)) -secret = 'SEC80ae01de9c486a9f8531d4ec1ed09b8fbd5d9cc1b0ba171b0493f9bebfeb4807' +secret = 'SEC80ae01de9c486a9f8531d4ec1ed09b8fbd5d9cc1b0ba171b0493f9bebfeb4807' #正式的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=775093d6cbe22673b65e506f20aea7036cc58c4b9e89850f660eb798e4c149f6' #正式的webhook class webhookHandler: - def __init__(self,webhookUrl = f"https://oapi.dingtalk.com/robot/send?access_token=775093d6cbe22673b65e506f20aea7036cc58c4b9e89850f660eb798e4c149f6×tamp={timestamp}&sign={sign}"): + def __init__(self,webhookUrl = f"{webhook_url}×tamp={timestamp}&sign={sign}"): self.webhookUrl = webhookUrl @@ -49,4 +50,3 @@ class webhookHandler: res = requests.post(url=self.webhookUrl,data=data) webhook = webhookHandler() -webhook.getToken() \ No newline at end of file -- GitLab