mirror of https://gitlab.com/litecord/litecord.git
fix tests
This commit is contained in:
parent
30902d6e8f
commit
74c03f7dfa
|
|
@ -56,6 +56,7 @@ class TestClient:
|
||||||
user and adds authorization headers to test requests."""
|
user and adds authorization headers to test requests."""
|
||||||
def __init__(self, test_cli, test_user):
|
def __init__(self, test_cli, test_user):
|
||||||
self.cli = test_cli
|
self.cli = test_cli
|
||||||
|
self.app = test_cli.app
|
||||||
self.user = test_user
|
self.user = test_user
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
|
|
@ -78,6 +79,11 @@ class TestClient:
|
||||||
kwargs['headers'] = self._inject_auth(kwargs)
|
kwargs['headers'] = self._inject_auth(kwargs)
|
||||||
return await self.cli.post(*args, **kwargs)
|
return await self.cli.post(*args, **kwargs)
|
||||||
|
|
||||||
|
async def put(self, *args, **kwargs):
|
||||||
|
"""Send a POST request."""
|
||||||
|
kwargs['headers'] = self._inject_auth(kwargs)
|
||||||
|
return await self.cli.put(*args, **kwargs)
|
||||||
|
|
||||||
async def patch(self, *args, **kwargs):
|
async def patch(self, *args, **kwargs):
|
||||||
"""Send a PATCH request."""
|
"""Send a PATCH request."""
|
||||||
kwargs['headers'] = self._inject_auth(kwargs)
|
kwargs['headers'] = self._inject_auth(kwargs)
|
||||||
|
|
|
||||||
|
|
@ -63,13 +63,13 @@ async def test_guild_fetch(test_cli_staff):
|
||||||
try:
|
try:
|
||||||
await _fetch_guild(test_cli_staff, guild_id)
|
await _fetch_guild(test_cli_staff, guild_id)
|
||||||
finally:
|
finally:
|
||||||
await delete_guild(int(guild_id), app_=test_cli_staff.test_cli.app)
|
await delete_guild(int(guild_id), app_=test_cli_staff.app)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_guild_update(test_cli_staff):
|
async def test_guild_update(test_cli_staff):
|
||||||
"""Test the update of a guild via the Admin API."""
|
"""Test the update of a guild via the Admin API."""
|
||||||
rjson = await _create_guild(test_cli_staff, token=token)
|
rjson = await _create_guild(test_cli_staff)
|
||||||
guild_id = rjson['id']
|
guild_id = rjson['id']
|
||||||
assert not rjson['unavailable']
|
assert not rjson['unavailable']
|
||||||
|
|
||||||
|
|
@ -78,11 +78,9 @@ async def test_guild_update(test_cli_staff):
|
||||||
# would be overkill to test the side-effects, so... I'm not
|
# would be overkill to test the side-effects, so... I'm not
|
||||||
# testing them. Yes, I know its a bad idea, but if someone has an easier
|
# testing them. Yes, I know its a bad idea, but if someone has an easier
|
||||||
# way to write that, do send an MR.
|
# way to write that, do send an MR.
|
||||||
resp = await test_cli.patch(
|
resp = await test_cli_staff.patch(
|
||||||
f'/api/v6/admin/guilds/{guild_id}',
|
f'/api/v6/admin/guilds/{guild_id}',
|
||||||
headers={
|
json={
|
||||||
'Authorization': token
|
|
||||||
}, json={
|
|
||||||
'unavailable': True
|
'unavailable': True
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -95,7 +93,7 @@ async def test_guild_update(test_cli_staff):
|
||||||
rjson = await _fetch_guild(test_cli_staff, guild_id)
|
rjson = await _fetch_guild(test_cli_staff, guild_id)
|
||||||
assert rjson['unavailable']
|
assert rjson['unavailable']
|
||||||
finally:
|
finally:
|
||||||
await delete_guild(int(guild_id), app_=test_cli_staff.test_cli.app)
|
await delete_guild(int(guild_id), app_=test_cli_staff.app)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
@ -118,4 +116,4 @@ async def test_guild_delete(test_cli_staff):
|
||||||
assert rjson['error']
|
assert rjson['error']
|
||||||
assert rjson['code'] == GuildNotFound.error_code
|
assert rjson['code'] == GuildNotFound.error_code
|
||||||
finally:
|
finally:
|
||||||
await delete_guild(int(guild_id), app_=test_cli.app)
|
await delete_guild(int(guild_id), app_=test_cli_staff.app)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import secrets
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tests.credentials import CREDS
|
|
||||||
from litecord.enums import UserFlags
|
from litecord.enums import UserFlags
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -98,7 +97,7 @@ async def test_create_delete(test_cli_staff):
|
||||||
assert isinstance(rjson, list)
|
assert isinstance(rjson, list)
|
||||||
assert rjson[0]['id'] == genned_uid
|
assert rjson[0]['id'] == genned_uid
|
||||||
finally:
|
finally:
|
||||||
await _del_user(test_cli_staff, genned_uid, token=token)
|
await _del_user(test_cli_staff, genned_uid)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
@ -126,4 +125,4 @@ async def test_user_update(test_cli_staff):
|
||||||
# TODO: maybe we can check for side effects by fetching the
|
# TODO: maybe we can check for side effects by fetching the
|
||||||
# user manually too...
|
# user manually too...
|
||||||
finally:
|
finally:
|
||||||
await _del_user(test_cli, user_id, token=token)
|
await _del_user(test_cli_staff, user_id)
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ async def test_gw(test_cli):
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_ready(test_cli_user):
|
async def test_ready(test_cli_user):
|
||||||
conn = await gw_start(test_cli_user.test_cli)
|
conn = await gw_start(test_cli_user.cli)
|
||||||
|
|
||||||
# get the hello frame but ignore it
|
# get the hello frame but ignore it
|
||||||
await _json(conn)
|
await _json(conn)
|
||||||
|
|
@ -111,7 +111,7 @@ async def test_ready(test_cli_user):
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_ready_fields(test_cli_user):
|
async def test_ready_fields(test_cli_user):
|
||||||
conn = await gw_start(test_cli_user.test_cli)
|
conn = await gw_start(test_cli_user.cli)
|
||||||
|
|
||||||
# get the hello frame but ignore it
|
# get the hello frame but ignore it
|
||||||
await _json(conn)
|
await _json(conn)
|
||||||
|
|
@ -151,7 +151,7 @@ async def test_ready_fields(test_cli_user):
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_heartbeat(test_cli_user):
|
async def test_heartbeat(test_cli_user):
|
||||||
conn = await gw_start(test_cli_user.test_cli)
|
conn = await gw_start(test_cli_user.cli)
|
||||||
|
|
||||||
# get the hello frame but ignore it
|
# get the hello frame but ignore it
|
||||||
await _json(conn)
|
await _json(conn)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue