Example #1
0
def test_layout_smart_wrapping(page_layout):
    strings = ["first", "second", "third"]
    output = page_layout + la.Section(
        children=[
            la.Row(children=[*strings, "fourth"]),
            "another bit of content",
            la.Row(children=[la.Column(children=["fifth"]), "sixth"]),
        ]
    )
    expected = page_layout
    expected += la.Section(
        children=[
            la.Row(children=[*[co.Markdown(x) for x in strings], "fourth"]),
            co.Markdown("another bit of content"),
            la.Row(
                children=[
                    la.Column(children=[co.Markdown("fifth")]),
                    la.Column(children=[co.Markdown("sixth")]),
                ]
            ),
        ]
    )
    print(output)
    print()
    print(expected)
    assert output == expected
Example #2
0
def test_set_column_as_dict(page_basic_layout):
    page = la.Page(title="Test Page")

    expected = page_basic_layout
    expected[0][0][0] = la.Column(title="Column One", children=["markdown content"])

    page["Section One"]["Row One"]["Wrong Title"] = {"Column One": "markdown content"}

    assert page == expected
Example #3
0
def page_basic_layout() -> la.Page:
    page = la.Page(
        title="Test Page",
        children=la.Section(
            title="Section One",
            children=la.Row(
                title="Row One",
                children=la.Column(children=co.Markdown("markdown content")),
            ),
        ),
    )
    return page
Example #4
0
def test_set_column_extra_children():
    expected = la.Page(
        children=la.Section(
            children=la.Row(
                children=la.Column(children=["markdown", "content", "tuple"]),
            ),
        ),
    )
    output_page = la.Page()
    output_page[0][0][0] = ("markdown", "content", "tuple")
    print(output_page)
    assert output_page == expected
Example #5
0
def page_layout(content_list_fn) -> la.Page:
    return la.Page(
        title="jazz",
        children=la.Section(children=la.Row(
            children=[la.Column(children=[x]) for x in content_list_fn])),
    )
Example #6
0
with Path(_irises_path).open("rb") as f:
    _irises_binary = BytesIO(f.read())

# Add new content classes here
content_list = [
    (co.Markdown("this _is_ some **markdown**")),
    (co.RawHTML("<p>Raw HTML</p>")),
]

# Add new layout classes here
layout_list = [
    (la.Page(children=[*content_list])),
    (la.Section(children=[*content_list])),
    (la.Row(children=[*content_list])),
    (la.Column(children=[*content_list])),
    (la.Card(children=[*content_list])),
    (la.CardSection(children=[*content_list])),
    (la.CardRow(children=[*content_list])),
    (la.Spacer()),
    (la.PageBreak()),
]

# Add new adaptor types here
adaptor_list = [
    ("this is markdown", co.Markdown),
    ({
        "key": "value"
    }, dict),
    (Path(_markdown_path), co.Markdown),
]
Example #7
0
def test_rshift_tuple():
    col = la.Column(title="title")
    passthrough = col >> ("a", "b")
    assert passthrough == la.Column(title="title", children=["a", "b"])
Example #8
0
def test_lshift_tuple():
    col = la.Column(title="title")
    content = ("a", "b")
    passthrough = col << ("a", "b")
    assert passthrough == content
    assert col == la.Column(title="title", children=["a", "b"])
Example #9
0
    a = la.Page(title="jazz", children=content_list_fn)
    assert a == page_layout


def test_layout_equality(layout_list_fn):
    for i, a in enumerate(layout_list_fn):
        for j, b in enumerate(layout_list_fn):
            if i == j:
                assert a == b
            else:
                assert a != b


layout_add_list = [
    (
        la.Column(),
        "miles davis",
        la.Column(children=co.Markdown("miles davis")),
    ),
    (
        la.Row(),
        co.Markdown("ornette coleman"),
        la.Row(children=la.Column(children=co.Markdown("ornette coleman"))),
    ),
    (
        la.Page(children=["charles mingus"]),
        la.Section(children=["thelonious monk"]),
        la.Page(
            children=[
                la.Section(children=["charles mingus"]),
                la.Section(children=["thelonious monk"]),