From 005af6cae91beeec4663938f64f0f073f9551dd4 Mon Sep 17 00:00:00 2001 From: Carson McManus Date: Thu, 22 Apr 2021 10:22:14 -0400 Subject: [PATCH] add assert_has_embed, make assert_embed_equals/regex check that embeds are present --- distest/TestInterface/_embeds.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/distest/TestInterface/_embeds.py b/distest/TestInterface/_embeds.py index 797b174..6d46bff 100644 --- a/distest/TestInterface/_embeds.py +++ b/distest/TestInterface/_embeds.py @@ -5,6 +5,14 @@ import re +async def assert_has_embed(message: Message): + """Assert that ``message`` is a message that has an embed. If the embed is not present, fail the test. + + :param message: original message + """ + if len(message.embeds) == 0: + raise ResponseDidNotMatchError("The message is missing an embed.") + async def assert_embed_equals( message: Message, matches: Embed, attributes_to_prove: list = None, @@ -21,6 +29,7 @@ async def assert_embed_equals( :return: message :rtype: discord.Message """ + assert_has_embed(message) # All possible attributes a user can set during initialisation possible_attributes = [ @@ -90,6 +99,7 @@ async def assert_embed_regex(message: Message, patterns: Dict[str, str]): :return: message :rtype: discord.Message """ + assert_has_embed(message) possible_attributes = [ "title",