Commit 3ff7481c authored by zhanhuasheng's avatar zhanhuasheng

改动断言方式

parent 84731b0f
...@@ -5,7 +5,7 @@ from Utils.global_variate import Global ...@@ -5,7 +5,7 @@ from Utils.global_variate import Global
from TestData.inbox.livechat_test_data import livechatData from TestData.inbox.livechat_test_data import livechatData
loop = asyncio.get_event_loop() #异步主线 loop = asyncio.get_event_loop() #异步主线
loop.set_debug(True)
class ws: class ws:
def __init__(self, url, attr): def __init__(self, url, attr):
...@@ -83,8 +83,19 @@ async def ws_action(ws,case): ...@@ -83,8 +83,19 @@ async def ws_action(ws,case):
action = case['action'] #操作 action = case['action'] #操作
if action == 'sendmsg': if action == 'sendmsg':
response = await ws_send_handler(case=case,ws=ws) response = await ws_send_handler(case=case,ws=ws)
if response.get('code'):
assert response['code'] == 200
else:
assert response['response']['code'] == 200 assert response['response']['code'] == 200
assert response['action'] == 'sendmsg' # type = case['data']['type']
# if type in ['emoji','file','link','rate','product']:
# if type not in ['file','rate','emoji']: #type等于file的时候,后端返回的action,willdesk端是sendmsg,c端又是readMsg,干脆不作判断了
# assert response['data']['action'] == 'sendmsg'
#
# else:
# assert response['response']['code'] == 200
# assert response['action'] == 'sendmsg'
elif action == 'receive': elif action == 'receive':
expected = case['expected'] # 断言 expected = case['expected'] # 断言
...@@ -189,7 +200,7 @@ async def ws_run(ws,case): ...@@ -189,7 +200,7 @@ async def ws_run(ws,case):
:param case: 传入用例数据 :param case: 传入用例数据
''' '''
# asyncio.run(ws_action(ws=ws,case=case)) # asyncio.run(ws_action(ws=ws,case=case))
task = asyncio.ensure_future(ws_action(ws=ws,case=case)) task = asyncio.create_task(ws_action(ws=ws,case=case))
await asyncio.wait_for(task,timeout=10) await asyncio.wait_for(task,timeout=10)
# loop.run_until_complete(ws_action(ws=ws,case=case)) # loop.run_until_complete(ws_action(ws=ws,case=case))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment