mirror of https://gitlab.com/litecord/litecord.git
guilds: remove app_ param from delete_guild()
This commit is contained in:
parent
420646e76f
commit
2780ca4175
|
|
@ -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("/<int:guild_id>", methods=["DELETE"])
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Reference in New Issue