aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar kosayoda <[email protected]>2021-04-12 23:14:08 +0800
committerGravatar kosayoda <[email protected]>2021-04-12 23:14:08 +0800
commit48a7cca5c90841679a71eb8d0e902ad6dc943cc6 (patch)
tree5511c136833aa07efc89c3eac98a9eb013cb53ca /tests
parentupdate comment (diff)
parentMerge pull request #1516 from ToxicKidz/sorted-available-channels (diff)
Merge branch 'main' into doc-imp
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/exts/info/test_information.py20
-rw-r--r--tests/bot/utils/test_services.py4
2 files changed, 11 insertions, 13 deletions
diff --git a/tests/bot/exts/info/test_information.py b/tests/bot/exts/info/test_information.py
index 80731c9f0..a996ce477 100644
--- a/tests/bot/exts/info/test_information.py
+++ b/tests/bot/exts/info/test_information.py
@@ -283,6 +283,7 @@ class UserEmbedTests(unittest.IsolatedAsyncioTestCase):
user = helpers.MockMember()
user.nick = None
user.__str__ = unittest.mock.Mock(return_value="Mr. Hemlock")
+ user.colour = 0
embed = await self.cog.create_user_embed(ctx, user)
@@ -298,6 +299,7 @@ class UserEmbedTests(unittest.IsolatedAsyncioTestCase):
user = helpers.MockMember()
user.nick = "Cat lover"
user.__str__ = unittest.mock.Mock(return_value="Mr. Hemlock")
+ user.colour = 0
embed = await self.cog.create_user_embed(ctx, user)
@@ -311,10 +313,9 @@ class UserEmbedTests(unittest.IsolatedAsyncioTestCase):
"""Created `!user` embeds should not contain mention of the @everyone-role."""
ctx = helpers.MockContext(channel=helpers.MockTextChannel(id=1))
admins_role = helpers.MockRole(name='Admins')
- admins_role.colour = 100
# A `MockMember` has the @Everyone role by default; we add the Admins to that.
- user = helpers.MockMember(roles=[admins_role], top_role=admins_role)
+ user = helpers.MockMember(roles=[admins_role], colour=100)
embed = await self.cog.create_user_embed(ctx, user)
@@ -332,12 +333,11 @@ class UserEmbedTests(unittest.IsolatedAsyncioTestCase):
ctx = helpers.MockContext(channel=helpers.MockTextChannel(id=50))
moderators_role = helpers.MockRole(name='Moderators')
- moderators_role.colour = 100
infraction_counts.return_value = ("Infractions", "expanded infractions info")
nomination_counts.return_value = ("Nominations", "nomination info")
- user = helpers.MockMember(id=314, roles=[moderators_role], top_role=moderators_role)
+ user = helpers.MockMember(id=314, roles=[moderators_role], colour=100)
embed = await self.cog.create_user_embed(ctx, user)
infraction_counts.assert_called_once_with(user)
@@ -367,11 +367,10 @@ class UserEmbedTests(unittest.IsolatedAsyncioTestCase):
ctx = helpers.MockContext(channel=helpers.MockTextChannel(id=100))
moderators_role = helpers.MockRole(name='Moderators')
- moderators_role.colour = 100
infraction_counts.return_value = ("Infractions", "basic infractions info")
- user = helpers.MockMember(id=314, roles=[moderators_role], top_role=moderators_role)
+ user = helpers.MockMember(id=314, roles=[moderators_role], colour=100)
embed = await self.cog.create_user_embed(ctx, user)
infraction_counts.assert_called_once_with(user)
@@ -407,12 +406,11 @@ class UserEmbedTests(unittest.IsolatedAsyncioTestCase):
ctx = helpers.MockContext()
moderators_role = helpers.MockRole(name='Moderators')
- moderators_role.colour = 100
- user = helpers.MockMember(id=314, roles=[moderators_role], top_role=moderators_role)
+ user = helpers.MockMember(id=314, roles=[moderators_role], colour=100)
embed = await self.cog.create_user_embed(ctx, user)
- self.assertEqual(embed.colour, discord.Colour(moderators_role.colour))
+ self.assertEqual(embed.colour, discord.Colour(100))
@unittest.mock.patch(
f"{COG_PATH}.basic_user_infraction_counts",
@@ -422,7 +420,7 @@ class UserEmbedTests(unittest.IsolatedAsyncioTestCase):
"""The embed should be created with a blurple colour if the user has no assigned roles."""
ctx = helpers.MockContext()
- user = helpers.MockMember(id=217)
+ user = helpers.MockMember(id=217, colour=discord.Colour.default())
embed = await self.cog.create_user_embed(ctx, user)
self.assertEqual(embed.colour, discord.Colour.blurple())
@@ -435,7 +433,7 @@ class UserEmbedTests(unittest.IsolatedAsyncioTestCase):
"""The embed thumbnail should be set to the user's avatar in `png` format."""
ctx = helpers.MockContext()
- user = helpers.MockMember(id=217)
+ user = helpers.MockMember(id=217, colour=0)
user.avatar_url_as.return_value = "avatar url"
embed = await self.cog.create_user_embed(ctx, user)
diff --git a/tests/bot/utils/test_services.py b/tests/bot/utils/test_services.py
index 1b48f6560..3b71022db 100644
--- a/tests/bot/utils/test_services.py
+++ b/tests/bot/utils/test_services.py
@@ -30,9 +30,9 @@ class PasteTests(unittest.IsolatedAsyncioTestCase):
"""Url with specified extension is returned on successful requests."""
key = "paste_key"
test_cases = (
- (f"https://paste_service.com/{key}.txt", "txt"),
+ (f"https://paste_service.com/{key}.txt?noredirect", "txt"),
(f"https://paste_service.com/{key}.py", "py"),
- (f"https://paste_service.com/{key}", ""),
+ (f"https://paste_service.com/{key}?noredirect", ""),
)
response = MagicMock(
json=AsyncMock(return_value={"key": key})