From 2780ca41750504de926c4b7c55d57d65e714b274 Mon Sep 17 00:00:00 2001 From: Luna Date: Fri, 25 Oct 2019 10:24:20 -0300 Subject: [PATCH] guilds: remove app_ param from delete_guild() --- litecord/blueprints/guilds.py | 16 +++++++--------- tests/test_admin_api/test_guilds.py | 11 ++++++++--- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/litecord/blueprints/guilds.py b/litecord/blueprints/guilds.py index 7db4224..ce2b78b 100644 --- a/litecord/blueprints/guilds.py +++ b/litecord/blueprints/guilds.py @@ -393,20 +393,18 @@ async def _update_guild(guild_id): return jsonify(guild) -async def delete_guild(guild_id: int, *, app_=None): +async def delete_guild(guild_id: int): """Delete a single guild.""" - app_ = app_ or app - - await app_.db.execute( + await app.db.execute( """ - DELETE FROM guilds - WHERE guilds.id = $1 - """, + DELETE FROM guilds + WHERE guilds.id = $1 + """, guild_id, ) # Discord's client expects IDs being string - await app_.dispatcher.dispatch( + await app.dispatcher.dispatch( "guild", guild_id, "GUILD_DELETE", @@ -420,7 +418,7 @@ async def delete_guild(guild_id: int, *, app_=None): # remove from the dispatcher so nobody # becomes the little memer that tries to fuck up with # everybody's gateway - await app_.dispatcher.remove("guild", guild_id) + await app.dispatcher.remove("guild", guild_id) @bp.route("/", methods=["DELETE"]) diff --git a/tests/test_admin_api/test_guilds.py b/tests/test_admin_api/test_guilds.py index b6619e7..6ca61cb 100644 --- a/tests/test_admin_api/test_guilds.py +++ b/tests/test_admin_api/test_guilds.py @@ -54,6 +54,11 @@ async def _fetch_guild(test_cli_staff, guild_id, *, ret_early=False): return rjson +async def _delete_guild(test_cli, guild_id: int): + async with test_cli.app.app_context(): + await delete_guild(int(guild_id)) + + @pytest.mark.asyncio async def test_guild_fetch(test_cli_staff): """Test the creation and fetching of a guild via the Admin API.""" @@ -63,7 +68,7 @@ async def test_guild_fetch(test_cli_staff): try: await _fetch_guild(test_cli_staff, guild_id) finally: - await delete_guild(int(guild_id), app_=test_cli_staff.app) + await _delete_guild(test_cli_staff, int(guild_id)) @pytest.mark.asyncio @@ -91,7 +96,7 @@ async def test_guild_update(test_cli_staff): rjson = await _fetch_guild(test_cli_staff, guild_id) assert rjson["unavailable"] finally: - await delete_guild(int(guild_id), app_=test_cli_staff.app) + await _delete_guild(test_cli_staff, int(guild_id)) @pytest.mark.asyncio @@ -113,4 +118,4 @@ async def test_guild_delete(test_cli_staff): assert rjson["error"] assert rjson["code"] == GuildNotFound.error_code finally: - await delete_guild(int(guild_id), app_=test_cli_staff.app) + await _delete_guild(test_cli_staff, int(guild_id))