Commit a6ecc84b authored by Luna's avatar Luna 😻

test_admin_api/test_guilds: add test_guild_update

 - docs/admin_api.md: add note on unavailable guild object being
 returned
parent d8b889c1
Pipeline #57773538 passed with stages
in 8 minutes and 44 seconds
......@@ -155,9 +155,9 @@ Returns a partial guild object.
### PATCH `/guilds/<guild_id>`
Update a single guild.
Dispatches `GUILD_UPDATE` to subscribers of the guild.
Dispatches `GUILD_UPDATE` to subscribers of the guild, returns the guild object
on success.
Returns a guild object or an unavailable guild object on success.
| field | type | description |
| --: | :-- | :-- |
......
......@@ -62,3 +62,33 @@ async def test_guild_fetch(test_cli):
assert rjson['id'] == guild_id
finally:
await delete_guild(int(guild_id), app_=test_cli.app)
@pytest.mark.asyncio
async def test_guild_update(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']
assert not rjson['unavailable']
try:
# I believe setting up an entire gateway client registered to the guild
# 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
# way to write that, do send an MR.
resp = await test_cli.patch(
f'/api/v6/admin/guilds/{guild_id}',
headers={
'Authorization': token
}, json={
'unavailable': True
})
assert resp.status_code == 200
rjson = await resp.json
assert isinstance(rjson, dict)
assert rjson['id'] == guild_id
assert rjson['unavailable']
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