Commit 16159520 authored by zhanhuasheng's avatar zhanhuasheng

新增关闭数据库链接、异步任务

parent a5d7c0ac
import asyncio
from Utils.sql_handler import test_env_conn
import pytest import pytest
import requests import requests
import time import time
...@@ -88,6 +90,7 @@ def customer_login(): ...@@ -88,6 +90,7 @@ def customer_login():
login_res = session.post(url=login_url,json=data,headers=headers).json() login_res = session.post(url=login_url,json=data,headers=headers).json()
setattr(global_variate.Global,'clientToken',login_res['data']['accessToken']) setattr(global_variate.Global,'clientToken',login_res['data']['accessToken'])
setattr(global_variate.Global,'customerId',login_res['data']['customerId']) setattr(global_variate.Global,'customerId',login_res['data']['customerId'])
setattr(global_variate.Global,'customerName',login_res['data']['name'])
address = 'wss://atestws.sealapps.com/ws' if env == 'test' else 'wss://ws.willdesk.com/ws' address = 'wss://atestws.sealapps.com/ws' if env == 'test' else 'wss://ws.willdesk.com/ws'
print(f'{address}?platform=1&authorization={global_variate.Global.access_token}&t={int(time.time())}') print(f'{address}?platform=1&authorization={global_variate.Global.access_token}&t={int(time.time())}')
...@@ -98,9 +101,17 @@ def customer_login(): ...@@ -98,9 +101,17 @@ def customer_login():
url=f'{address}?platform=1&authorization={global_variate.Global.clientToken}&t={int(time.time())}', url=f'{address}?platform=1&authorization={global_variate.Global.clientToken}&t={int(time.time())}',
attr='customer') # c端websocket链接 attr='customer') # c端websocket链接
async def close_ws():
await asyncio.gather(asyncio.create_task(websocket_handler.ws_willdesk.close()),asyncio.create_task(websocket_handler.ws_client.close()))
@pytest.fixture(scope='session',autouse=True) @pytest.fixture(scope='session',autouse=True)
def call_fixture(): def call_fixture():
#自定义调用顺序 #自定义调用顺序
willdesk_login() willdesk_login()
customer_login() customer_login()
\ No newline at end of file yield
test_env_conn.close_db()
loop = websocket_handler.loop
loop.run_until_complete(close_ws())
loop.stop()
loop.close()
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