mirror of https://gitlab.com/litecord/litecord.git
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:
parent
d8b889c1a9
commit
a6ecc84b9f
|
|
@ -155,9 +155,9 @@ Returns a partial guild object.
|
||||||
### PATCH `/guilds/<guild_id>`
|
### PATCH `/guilds/<guild_id>`
|
||||||
|
|
||||||
Update a single guild.
|
Update a single guild.
|
||||||
|
Dispatches `GUILD_UPDATE` to subscribers of the guild.
|
||||||
|
|
||||||
Dispatches `GUILD_UPDATE` to subscribers of the guild, returns the guild object
|
Returns a guild object or an unavailable guild object on success.
|
||||||
on success.
|
|
||||||
|
|
||||||
| field | type | description |
|
| field | type | description |
|
||||||
| --: | :-- | :-- |
|
| --: | :-- | :-- |
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,33 @@ async def test_guild_fetch(test_cli):
|
||||||
assert rjson['id'] == guild_id
|
assert rjson['id'] == guild_id
|
||||||
finally:
|
finally:
|
||||||
await delete_guild(int(guild_id), app_=test_cli.app)
|
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)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue