From 36cc01b691bb88f2093803af952df19a048c11d5 Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Fri, 19 Apr 2024 17:36:49 +0800 Subject: [PATCH] bugfix --- TestData/setting/email_integration_test_data.py | 2 +- TestFile/account/account_selectLanguage.py | 5 +++-- .../emailIntegration/emailIntegration_insert.py | 10 ++++++++++ YamlCase/account/account.yaml | 8 ++++++++ YamlCase/setting/emailIntegration.yaml | 1 + main.py | 5 +++-- 6 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 TestFile/setting/emailIntegration/emailIntegration_insert.py diff --git a/TestData/setting/email_integration_test_data.py b/TestData/setting/email_integration_test_data.py index 2eead25..e4bf3e7 100644 --- a/TestData/setting/email_integration_test_data.py +++ b/TestData/setting/email_integration_test_data.py @@ -4,4 +4,4 @@ class emailIntegrationData(Global): append_email_address = 'autotest@channelwill.cn' append_email_name = 'autotest' append_email_status = 0 - new_email_name = 'autotest2' \ No newline at end of file + new_email_name = 'autotest2' diff --git a/TestFile/account/account_selectLanguage.py b/TestFile/account/account_selectLanguage.py index 97d1ee9..06a0d4a 100644 --- a/TestFile/account/account_selectLanguage.py +++ b/TestFile/account/account_selectLanguage.py @@ -1,6 +1,7 @@ from Utils.sql_handler import test_env_conn from TestData.account.account_test_data import accountData -select_sql = f'select * from willdesk.customer_service where id = {accountData.userId} ' +select_sql = f'select * from willdesk.customer_service where id = {accountData.userId}' select_result = test_env_conn.select_one_value(sql=select_sql) -assert select_result['local_lang'] == accountData.target_language \ No newline at end of file +setattr(accountData, 'local_lang', select_result['local_lang']) +# assert select_result['local_lang'] == accountData.target_language \ No newline at end of file diff --git a/TestFile/setting/emailIntegration/emailIntegration_insert.py b/TestFile/setting/emailIntegration/emailIntegration_insert.py new file mode 100644 index 0000000..18a69c3 --- /dev/null +++ b/TestFile/setting/emailIntegration/emailIntegration_insert.py @@ -0,0 +1,10 @@ +from Utils.sql_handler import test_env_conn +from TestData.setting.email_integration_test_data import emailIntegrationData + +email_select_sql = f'select * from `email_config` where brand_id = {emailIntegrationData.brandId} and email = "{emailIntegrationData.append_email_address}"' +email_select_result = test_env_conn.select_one_value(email_select_sql) +if not email_select_result: + email_insert_sql = f"""INSERT INTO willdesk.email_config (brand_id,email_servicer_id,email,email_name,auth_code,refresh_token,raw_token,code_type,imap_addr,imap_port,imap_ssl,smtp_addr,smtp_port,smtp_ssl,enable_signature,signature_content,auth_folder,connect_status,failed_reason,status,create_at,update_at) VALUES + ({emailIntegrationData.brandId},7,'{emailIntegrationData.append_email_address}','{emailIntegrationData.append_email_name}','OJezniff5cTye4CqPyr3KA5F8HwmLiwyTAlBvYRKeWw=','','',0,'imap.com',993,0,'smtp.com',587,0,0,'

Best wishes 

Agent name | Customer Support','1',1,'',{emailIntegrationData.append_email_status},'2024-04-19 17:11:37','2024-04-19 17:11:48'); +""" + test_env_conn.execute_sql(email_insert_sql) \ No newline at end of file diff --git a/YamlCase/account/account.yaml b/YamlCase/account/account.yaml index 7b85d55..8cd63cb 100644 --- a/YamlCase/account/account.yaml +++ b/YamlCase/account/account.yaml @@ -51,6 +51,14 @@ api6: expected: - eq: {"$.code" : 0} +api7: + title: 检查设置语言 + url: /api/v1/customerService/getCustomerServiceInfo?v=${v} + method: get + expected: + - eq: { "$.code": 0 } + - eq: {"${local_lang}" : "${target_language}"} + api8: title: 检查翻译文本接口 url: /api/v1/translate/transKeyValue diff --git a/YamlCase/setting/emailIntegration.yaml b/YamlCase/setting/emailIntegration.yaml index a496a88..c531fd7 100644 --- a/YamlCase/setting/emailIntegration.yaml +++ b/YamlCase/setting/emailIntegration.yaml @@ -11,6 +11,7 @@ api2: title: 检查邮箱是否添加成功 url: /api/v1/email/listEmailConfig method: post + before_sql: /setting/emailIntegration/emailIntegration_insert.py data: {"v":"${v}"} expected: - eq: {"$.code": 0} diff --git a/main.py b/main.py index 93edb7c..81f915b 100644 --- a/main.py +++ b/main.py @@ -1,13 +1,14 @@ import pytest -import requests.exceptions from Utils.webhook_handler import webhook from Utils.sql_handler import test_env_conn +import os 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',f'--html=./report.html']) #allure报告一直生成不了,改用pytest自带报告 - + # pytest_run_command = 'pytest ./TestCase -vs -n=3 --reruns=1 --reruns-delay=3 --html=./report.html' + # os.system(pytest_run_command) finally: test_env_conn.close_db() #关闭数据库链接 -- GitLab