test_admin_api/test_guilds: add test_guild_update

- docs/admin_api.md: add note on unavailable guild object being
 returned
This commit is contained in:
Luna 2019-04-22 02:17:51 -03:00
parent d8b889c1a9
commit a6ecc84b9f
2 changed files with 32 additions and 2 deletions

View File

@ -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 |
| --: | :-- | :-- |

View File

@ -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)