mirror of https://gitlab.com/litecord/litecord.git
tests: attempt to fix flakey tests
This commit is contained in:
parent
eb93b7f912
commit
22f5af9887
|
|
@ -75,51 +75,53 @@ async def test_guild_fetch(test_cli_staff):
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_guild_update(test_cli_staff):
|
async def test_guild_update(test_cli_staff):
|
||||||
"""Test the update of a guild via the Admin API."""
|
"""Test the update of a guild via the Admin API."""
|
||||||
rjson = await _create_guild(test_cli_staff)
|
async with test_cli_staff.app.app_context():
|
||||||
guild_id = rjson["id"]
|
rjson = await _create_guild(test_cli_staff)
|
||||||
assert not rjson["unavailable"]
|
guild_id = rjson["id"]
|
||||||
|
assert not rjson["unavailable"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# I believe setting up an entire gateway client registered to the guild
|
# I believe setting up an entire gateway client registered to the guild
|
||||||
# would be overkill to test the side-effects, so... I'm not
|
# 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
|
# testing them. Yes, I know its a bad idea, but if someone has an easier
|
||||||
# way to write that, do send an MR.
|
# way to write that, do send an MR.
|
||||||
resp = await test_cli_staff.patch(
|
resp = await test_cli_staff.patch(
|
||||||
f"/api/v6/admin/guilds/{guild_id}", json={"unavailable": True}
|
f"/api/v6/admin/guilds/{guild_id}", json={"unavailable": True}
|
||||||
)
|
)
|
||||||
|
|
||||||
assert resp.status_code == 200
|
assert resp.status_code == 200
|
||||||
rjson = await resp.json
|
rjson = await resp.json
|
||||||
assert isinstance(rjson, dict)
|
assert isinstance(rjson, dict)
|
||||||
assert rjson["id"] == guild_id
|
assert rjson["id"] == guild_id
|
||||||
assert rjson["unavailable"]
|
assert rjson["unavailable"]
|
||||||
|
|
||||||
rjson = await _fetch_guild(test_cli_staff, guild_id)
|
rjson = await _fetch_guild(test_cli_staff, guild_id)
|
||||||
assert rjson["unavailable"]
|
assert rjson["unavailable"]
|
||||||
finally:
|
finally:
|
||||||
await _delete_guild(test_cli_staff, int(guild_id))
|
await _delete_guild(test_cli_staff, int(guild_id))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_guild_delete(test_cli_staff):
|
async def test_guild_delete(test_cli_staff):
|
||||||
"""Test the update of a guild via the Admin API."""
|
"""Test the update of a guild via the Admin API."""
|
||||||
rjson = await _create_guild(test_cli_staff)
|
async with test_cli_staff.app.app_context():
|
||||||
guild_id = rjson["id"]
|
rjson = await _create_guild(test_cli_staff)
|
||||||
|
guild_id = rjson["id"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp = await test_cli_staff.delete(f"/api/v6/admin/guilds/{guild_id}")
|
resp = await test_cli_staff.delete(f"/api/v6/admin/guilds/{guild_id}")
|
||||||
|
|
||||||
assert resp.status_code == 204
|
assert resp.status_code == 204
|
||||||
|
|
||||||
resp = await _fetch_guild(test_cli_staff, guild_id, ret_early=True)
|
resp = await _fetch_guild(test_cli_staff, guild_id, ret_early=True)
|
||||||
|
|
||||||
assert resp.status_code == 404
|
assert resp.status_code == 404
|
||||||
rjson = await resp.json
|
rjson = await resp.json
|
||||||
assert isinstance(rjson, dict)
|
assert isinstance(rjson, dict)
|
||||||
assert rjson["error"]
|
assert rjson["error"]
|
||||||
assert rjson["code"] == GuildNotFound.error_code
|
assert rjson["code"] == GuildNotFound.error_code
|
||||||
finally:
|
finally:
|
||||||
await _delete_guild(test_cli_staff, int(guild_id))
|
await _delete_guild(test_cli_staff, int(guild_id))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue