diff --git a/TestCase/inbox/test_06_channel.py b/TestCase/inbox/test_06_channel.py new file mode 100644 index 0000000000000000000000000000000000000000..14c87584c0888a3608e02301deb468b3843f260a --- /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 0000000000000000000000000000000000000000..5feb098d3d5857eec2b68ac00a1eac29d88bdf93 --- /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 0000000000000000000000000000000000000000..73079ddf0c7439cfd4683697304ab93e2c311792 --- /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 0000000000000000000000000000000000000000..6834a4469480c0acfaa01526bc5a562883ff7179 --- /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 cded230bd2866057ff8c75f409f073257e7ec7a0..ee09598dad050d1f85ba9f6a41f4d4ac61af8862 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 ddd4d2a9898fa4d9f1dfb12b838dcc639a3aa60b..a4f79198a3ac0437ddbcb9bb4e750898ed0a49af 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() #关闭数据库链接