diff --git a/tests/test_admin_api/test_guilds.py b/tests/test_admin_api/test_guilds.py index c89e484..0e38602 100644 --- a/tests/test_admin_api/test_guilds.py +++ b/tests/test_admin_api/test_guilds.py @@ -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)