diff options
author | 2020-02-05 11:37:20 -0800 | |
---|---|---|
committer | 2020-02-12 10:07:57 -0800 | |
commit | 562a33184b52525bc8f9cfda8aaeb8245087e135 (patch) | |
tree | d2b88f9c7af17329dbff9bf2a0b9a7f382b50d13 | |
parent | Sync tests: test Sync cog's on_member_update for roles (diff) |
Sync tests: test Sync cog's on_member_update for other attributes
Members should not be patched if other attributes have changed.
-rw-r--r-- | tests/bot/cogs/sync/test_cog.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/bot/cogs/sync/test_cog.py b/tests/bot/cogs/sync/test_cog.py index f04d53caa..36945b82e 100644 --- a/tests/bot/cogs/sync/test_cog.py +++ b/tests/bot/cogs/sync/test_cog.py @@ -2,6 +2,8 @@ import asyncio import unittest from unittest import mock +import discord + from bot import constants from bot.api import ResponseCodeError from bot.cogs import sync @@ -223,3 +225,22 @@ class SyncCogListenerTests(SyncCogTestCase): data = {"roles": sorted(role.id for role in after_member.roles)} self.cog.patch_user.assert_called_once_with(after_member.id, updated_information=data) + + def test_sync_cog_on_member_update_other(self): + """Members should not be patched if other attributes have changed.""" + subtests = ( + ("activities", discord.Game("Pong"), discord.Game("Frogger")), + ("nick", "old nick", "new nick"), + ("status", discord.Status.online, discord.Status.offline) + ) + + for attribute, old_value, new_value in subtests: + with self.subTest(attribute=attribute): + self.cog.patch_user.reset_mock() + + before_member = helpers.MockMember(**{attribute: old_value}) + after_member = helpers.MockMember(**{attribute: new_value}) + + asyncio.run(self.cog.on_member_update(before_member, after_member)) + + self.cog.patch_user.assert_not_called() |