Example #1
0
def test_nested_fmt() -> None:
    markdown = MarkdownBuilder(
        expr="{first}.for",
        fmt={
            "first": MarkdownBuilder(expr="1"),
        },
    )

    assert "1\n.for\n" == str(markdown)
Example #2
0
def test_deep_nested_fmt() -> None:
    inner_markdown = MarkdownBuilder(
        expr="{second}.to",
        fmt={
            "second": "two",
        },
    )

    markdown = MarkdownBuilder(
        expr="{first}.for",
        fmt={
            "first": inner_markdown,
        },
    )

    assert "two.to\n.for\n" == str(markdown)
Example #3
0
def test_single_fmt() -> None:
    markdown = MarkdownBuilder(
        expr="{first}.for",
        fmt={
            "first": "one",
        },
    )

    assert "one.for\n" == str(markdown)
Example #4
0
def test_double_fmt() -> None:
    markdown = MarkdownBuilder(
        expr="{first}.for.{second}",
        fmt={
            "first": "one",
            "second": "two",
        },
    )

    assert "one.for.two\n" == str(markdown)
Example #5
0
def test_not_enough_fmt() -> None:
    markdown = MarkdownBuilder(
        expr="{first}.for.{second}",
        fmt={
            "first": "one",
        },
    )

    with pytest.raises(Exception):
        str(markdown)
Example #6
0
def test_wrong_fmt() -> None:
    markdown = MarkdownBuilder(
        expr="{first}.for",
        fmt={
            "fist": "one",
        },
    )

    with pytest.raises(Exception):
        str(markdown)
Example #7
0
def test_default_style() -> None:
    markdown = MarkdownBuilder(expr="one")

    assert "one\n" == str(markdown)
Example #8
0
def test_link_image() -> None:
    markdown = MarkdownBuilder(expr="one").link_image(path="/image")

    assert "![one](/image)\n" == str(markdown)
Example #9
0
def test_ordered_list() -> None:
    markdown = MarkdownBuilder(expr="one").to_list(is_ordered=True)

    assert "1. one\n" == str(markdown)
Example #10
0
def test_change_end() -> None:
    markdown = MarkdownBuilder(expr="one", end="")

    assert "one" == str(markdown)
Example #11
0
def test_emoji() -> None:
    markdown = MarkdownBuilder(expr="one").to_emoji()

    assert ":one:\n" == str(markdown)
Example #12
0
def test_italic_next_bold() -> None:
    markdown = MarkdownBuilder(expr="one").to_bold().to_italic()

    assert "***one***\n" == str(markdown)
Example #13
0
def test_italic() -> None:
    markdown = MarkdownBuilder(expr="one").to_italic()

    assert "*one*\n" == str(markdown)
Example #14
0
def test_blockquote() -> None:
    markdown = MarkdownBuilder(expr="one").to_blockquote()

    assert ">one\n" == str(markdown)
Example #15
0
def test_unordered_list() -> None:
    markdown = MarkdownBuilder(expr="one").to_list(is_ordered=False)

    assert "- one\n" == str(markdown)
Example #16
0
def test_code() -> None:
    markdown = MarkdownBuilder(expr="one").to_code()

    assert "`one`\n" == str(markdown)
Example #17
0
def test_link_url() -> None:
    markdown = MarkdownBuilder(expr="one").link_url(path="/url")

    assert "[one](/url)\n" == str(markdown)
Example #18
0
def test_heading_right_level(level: int) -> None:
    markdown = MarkdownBuilder(expr="one").to_heading(level=level)

    assert "#" * level + " one\n" == str(markdown)
Example #19
0
def test_heading_wrong_level(level: int) -> None:
    with pytest.raises(Exception):
        MarkdownBuilder(expr="one").to_heading(level=level)