Commit 4142baa8 authored by Luna's avatar Luna 😻

test_admin_api/test_guilds: add test_guild_delete

parent b0c65c88
......@@ -44,6 +44,24 @@ async def _create_guild(test_cli, *, token=None):
return rjson
async def _fetch_guild(test_cli, guild_id, *, token=None, ret_early=False):
token = token or await login('admin', test_cli)
resp = await test_cli.get(f'/api/v6/admin/guilds/{guild_id}', headers={
'Authorization': token
})
if ret_early:
return resp
assert resp.status_code == 200
rjson = await resp.json
assert isinstance(rjson, dict)
assert rjson['id'] == guild_id
return rjson
@pytest.mark.asyncio
async def test_guild_fetch(test_cli):
"""Test the creation and fetching of a guild via the Admin API."""
......@@ -52,14 +70,7 @@ async def test_guild_fetch(test_cli):
guild_id = rjson['id']
try:
resp = await test_cli.get(f'/api/v6/admin/guilds/{guild_id}', headers={
'Authorization': token
})
assert resp.status_code == 200
rjson = await resp.json
assert isinstance(rjson, dict)
assert rjson['id'] == guild_id
await _fetch_guild(test_cli, guild_id)
finally:
await delete_guild(int(guild_id), app_=test_cli.app)
......@@ -92,3 +103,27 @@ async def test_guild_update(test_cli):
assert rjson['unavailable']
finally:
await delete_guild(int(guild_id), app_=test_cli.app)
@pytest.mark.asyncio
async def test_guild_delete(test_cli):
"""Test the update of a guild via the Admin API."""
token = await login('admin', test_cli)
rjson = await _create_guild(test_cli, token=token)
guild_id = rjson['id']
try:
resp = await test_cli.delete(
f'/api/v6/admin/guilds/{guild_id}',
headers={
'Authorization': token
})
assert resp.status_code == 204
resp = await _fetch_guild(test_cli, guild_id, token=token,
ret_early=True)
assert resp.status_code == 404
finally:
await delete_guild(int(guild_id), app_=test_cli.app)
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