From 9633580dbc3736f1ae8b408eb156a8ad12173dce Mon Sep 17 00:00:00 2001 From: zhanhuasheng Date: Tue, 26 Mar 2024 15:15:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TestCase/inbox/test_06_channel.py | 13 +++++++++++++ TestData/inbox/channel_test_data.py | 7 +++++++ TestFile/inbox/channel_select.py | 17 +++++++++++++++++ YamlCase/inbox/channel.yaml | 13 +++++++++++++ YamlCase/inbox/livechat.yaml | 8 ++++++++ main.py | 2 +- 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 TestCase/inbox/test_06_channel.py create mode 100644 TestData/inbox/channel_test_data.py create mode 100644 TestFile/inbox/channel_select.py create mode 100644 YamlCase/inbox/channel.yaml diff --git a/TestCase/inbox/test_06_channel.py b/TestCase/inbox/test_06_channel.py new file mode 100644 index 0000000..14c8758 --- /dev/null +++ b/TestCase/inbox/test_06_channel.py @@ -0,0 +1,13 @@ +import pytest +from Utils import yaml_handler +from Utils import req_handler +from TestData.inbox.channel_test_data import channelData + +class TestChannel: + + yaml_path = r'inbox\channel.yaml' + yaml_data = yaml_handler.yaml_handler.get_case(yaml_path) + @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/TestData/inbox/channel_test_data.py b/TestData/inbox/channel_test_data.py new file mode 100644 index 0000000..5feb098 --- /dev/null +++ b/TestData/inbox/channel_test_data.py @@ -0,0 +1,7 @@ +from Utils.global_variate import Global + +class channelData(Global): + pass + # brandId = 6052 + # shopId = 7238 + diff --git a/TestFile/inbox/channel_select.py b/TestFile/inbox/channel_select.py new file mode 100644 index 0000000..73079dd --- /dev/null +++ b/TestFile/inbox/channel_select.py @@ -0,0 +1,17 @@ +from Utils.sql_handler import test_env_conn +from TestData.inbox.channel_test_data import channelData + +channel_select_sql = f'select * from `resource_item` where brand_id = {channelData.brandId} and resource_id in (7,2,3,4,6)' #2:livechat 3:facebook 4:email 6:ins 7:whatsapp +channel_select_result = test_env_conn.select_many_value(sql=channel_select_sql) +channel_id = channel_select_result[0]['id'] +channel_name = channel_select_result[0]['name'] +channel_rel_id = channel_select_result[0]['rel_id'] +channel_resource_id = channel_select_result[0]['resource_id'] +setattr(channelData, 'channel_id', channel_id) +setattr(channelData, 'channel_name', channel_name) +setattr(channelData, 'channel_resource_id', channel_resource_id) + +channel_open_room_select_sql = f'select * from `im_room` where site_id = {channel_rel_id} and status = 1' +channel_open_room_select_result = test_env_conn.select_many_value(sql=channel_open_room_select_sql) +setattr(channelData, 'channel_open_room_num', len(channel_open_room_select_result)) + diff --git a/YamlCase/inbox/channel.yaml b/YamlCase/inbox/channel.yaml new file mode 100644 index 0000000..6834a44 --- /dev/null +++ b/YamlCase/inbox/channel.yaml @@ -0,0 +1,13 @@ +api1: + title: 检查渠道信息 + url: /api/v1/resource/getResourceItemList + method: post + before_sql: inbox/channel_select.py + data: {"resourceType":"channel","v":"${v}"} + expected: + - eq: {"$.code" : 0} + - eq: {"$.data.list[?(@.id == '${channel_id}')].name" : "${channel_name}"} + - eq: {"$.data.list[?(@.id == '${channel_id}')].openCount" : "${channel_open_room_num}"} + - eq: {"$.data.list[?(@.id == '${channel_id}')].resourceId" : "${channel_resource_id}"} + + diff --git a/YamlCase/inbox/livechat.yaml b/YamlCase/inbox/livechat.yaml index cded230..ee09598 100644 --- a/YamlCase/inbox/livechat.yaml +++ b/YamlCase/inbox/livechat.yaml @@ -158,3 +158,11 @@ api16: - eq: { "$.data.list[8].content": "${img}" } - like: { "$.data.list[8].senderUid": "${userId}" } +api17: + title: b端主动发起会话 - 笔记 + ws: willdesk + action: sendmsg + data: + type: text + roomId: "${roomId}" + isNote: true \ No newline at end of file diff --git a/main.py b/main.py index ddd4d2a..a4f7919 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_05_team.py',f'--alluredir=./allureReports','--clean-alluredir']) + pytest.main(['-vs',r'C:\Users\rd71\PycharmProjects\willdesk_api_auto\TestCase',f'--alluredir=./allureReports','--clean-alluredir']) finally: test_env_conn.close_db() #关闭数据库链接 -- GitLab