Пример #1
0
def test_get_information_block():
    link = "https://codedevils.org"
    text = "Visit our website"
    info_block = get_information_block(link=link, text=text)
    comp_block = MarkdownTextObject(
        text=":information_source: *<{}|{}>*".format(link, text)).render()
    assert info_block == comp_block
Пример #2
0
def get_information_block(link: str, text: str) -> dict:
    """
    Returns an information block, which is a section with an info icon followed by linked text.

    Args:
        link (str): The link the block redirects the user to.
        text (str): The link text.
    Returns:
        dict: A dict in the format of a context block.
    """
    information = ":information_source: *<{link}|{text}>*".format(link=link,
                                                                  text=text)
    return MarkdownTextObject(text=information).render()
Пример #3
0
def get_task_block(text: str, info_link: str, info_text: str) -> list:
    """
    Returns a task block, which is comprised of a paragraph of text followed by an information link at the bottom.

    Args:
        text (str): Markdown-supported text to display in the paragraph.
        info_link (str): The link associated with the task block.
        info_text (str): The link text.
    Returns:
        list: An array of blocks formatted for a block payload.
    """
    return [
        MarkdownTextObject(text=text).render(),
        get_information_block(link=info_link, text=info_text),
    ]
Пример #4
0
def get_text_block_with_image(text: str, image_url: str,
                              alt_text: str) -> dict:
    """
    Returns a text block with an image to the right of it.

    Args:
        text (str): The text in the text block.
        image_url (str): The URL to the image.
        alt_text (str): Alternate text (appears on image hover).
    Returns:
        dict: The block as a dict.
    """
    text_object = MarkdownTextObject(text=text)
    image_element = ImageElement(image_url=image_url, alt_text=alt_text)
    return get_text_block_with_accessory(text_object=text_object,
                                         accessory=image_element)
Пример #5
0
def test_markdown_text_object(markdown_text_object: MarkdownTextObject):
    assert markdown_text_object.render() == {
        "type": markdown_text_object.btype,
        "text": markdown_text_object.text,
        "verbatim": markdown_text_object.verbatim
    }
Пример #6
0
def markdown_text_object() -> MarkdownTextObject:
    return MarkdownTextObject(text="Markdown text object", emoji=False, verbatim=False)