Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

add assert_has_embed, make assert_embed_equals/regex check that embeds are present #65

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions distest/TestInterface/_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = [
Expand Down Expand Up @@ -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",
Expand Down