mirror of https://gitlab.com/litecord/litecord.git
tests.common: remove login() and get_uid()
This commit is contained in:
parent
a26f665c81
commit
f7de5c5596
|
|
@ -18,34 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
|
||||
import secrets
|
||||
from .credentials import CREDS
|
||||
|
||||
async def login(acc_name: str, test_cli):
|
||||
creds = CREDS[acc_name]
|
||||
|
||||
resp = await test_cli.post('/api/v6/auth/login', json={
|
||||
'email': creds['email'],
|
||||
'password': creds['password']
|
||||
})
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f'non-200 on login: {resp.status_code}')
|
||||
|
||||
rjson = await resp.json
|
||||
return rjson['token']
|
||||
|
||||
|
||||
async def get_uid(token, test_cli):
|
||||
resp = await test_cli.get('/api/v6/users/@me', headers={
|
||||
'Authorization': token
|
||||
})
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise RuntimeError(f'non-200 on get uid: {resp.status_code}')
|
||||
|
||||
rjson = await resp.json
|
||||
return rjson['id']
|
||||
|
||||
|
||||
def email() -> str:
|
||||
return f'{secrets.token_hex(5)}@{secrets.token_hex(5)}.com'
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import secrets
|
|||
import sys
|
||||
import os
|
||||
|
||||
import socket
|
||||
import pytest
|
||||
|
||||
# this is very hacky.
|
||||
|
|
|
|||
Loading…
Reference in New Issue