aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-01-02 09:31:09 -0800
committerGravatar MarkKoz <[email protected]>2020-02-12 10:07:48 -0800
commit86cdf82bc7fc96334994f8289f77ea3a6a14828b (patch)
tree25f60052ca11c12e50cc9515edd6fd1661933f9e
parentSync tests: remove diff test for updated and new roles together (diff)
Sync tests: remove guild_roles lists and assign roles to variables
Makes the creation of the expected diff clearer since the variable has a name compared to accessing some index of a list.
-rw-r--r--tests/bot/cogs/sync/test_roles.py22
1 files changed, 8 insertions, 14 deletions
diff --git a/tests/bot/cogs/sync/test_roles.py b/tests/bot/cogs/sync/test_roles.py
index ca9df4305..b9a4fe6cd 100644
--- a/tests/bot/cogs/sync/test_roles.py
+++ b/tests/bot/cogs/sync/test_roles.py
@@ -41,34 +41,28 @@ class RoleSyncerTests(unittest.TestCase):
def test_diff_for_updated_roles(self):
"""Only updated roles should be added to the 'updated' set of the diff."""
+ updated_role = {"id": 41, "name": "new", "colour": 33, "permissions": 0x8, "position": 1}
+
self.bot.api_client.get.return_value = [
{"id": 41, "name": "old", "colour": 33, "permissions": 0x8, "position": 1},
self.constant_role,
]
- guild_roles = [
- {"id": 41, "name": "new", "colour": 33, "permissions": 0x8, "position": 1},
- self.constant_role,
- ]
-
- guild = self.get_guild(*guild_roles)
+ guild = self.get_guild(updated_role, self.constant_role)
actual_diff = asyncio.run(self.syncer._get_diff(guild))
- expected_diff = (set(), {_Role(**guild_roles[0])}, set())
+ expected_diff = (set(), {_Role(**updated_role)}, set())
self.assertEqual(actual_diff, expected_diff)
def test_diff_for_new_roles(self):
"""Only new roles should be added to the 'created' set of the diff."""
- self.bot.api_client.get.return_value = [self.constant_role]
- guild_roles = [
- self.constant_role,
- {"id": 41, "name": "new", "colour": 33, "permissions": 0x8, "position": 1},
- ]
+ new_role = {"id": 41, "name": "new", "colour": 33, "permissions": 0x8, "position": 1}
- guild = self.get_guild(*guild_roles)
+ self.bot.api_client.get.return_value = [self.constant_role]
+ guild = self.get_guild(self.constant_role, new_role)
actual_diff = asyncio.run(self.syncer._get_diff(guild))
- expected_diff = ({_Role(**guild_roles[1])}, set(), set())
+ expected_diff = ({_Role(**new_role)}, set(), set())
self.assertEqual(actual_diff, expected_diff)