tests: add test_find_single_user with test resources

This commit is contained in:
Luna 2021-09-05 14:05:11 -03:00
parent 7b98b2332f
commit ddf27ace1a
1 changed files with 15 additions and 0 deletions

View File

@ -21,6 +21,7 @@ import secrets
import pytest import pytest
from tests.common import email
from litecord.enums import UserFlags from litecord.enums import UserFlags
@ -41,6 +42,20 @@ async def test_list_users(test_cli_staff):
assert rjson assert rjson
@pytest.mark.asyncio
async def test_find_single_user(test_cli_staff):
user = await test_cli_staff.create_user(
username="test_user" + secrets.token_hex(2), email=email()
)
resp = await _search(test_cli_staff, username=user.name)
assert resp.status_code == 200
rjson = await resp.json
assert isinstance(rjson, list)
fetched_user = rjson[0]
assert fetched_user["id"] == str(user.id)
async def _setup_user(test_cli) -> dict: async def _setup_user(test_cli) -> dict:
genned = secrets.token_hex(7) genned = secrets.token_hex(7)