Exemple #1
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
Exemple #2
0
def test_lshift(page_basic_layout):
    page = la.Page(title="Test Page")
    content = "markdown content"
    passthrough = page["Section One"]["Row One"] << content
    assert passthrough == content
    assert page.children == page_basic_layout.children
    assert page == page_basic_layout
Exemple #3
0
def test_set_row_as_dict_tuple():
    page = la.Page(title="Test Page")
    expected = copy(page)
    expected["Section One"]["Row One"]["Column One"] = "markdown content"
    expected["Section One"]["Row One"]["Column Two"] = "markdown content"
    page["Section One"]["Row One"] = {"Column One": "markdown content"}, {
        "Column Two": "markdown content"
    }
    assert page == expected
Exemple #4
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
Exemple #5
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
Exemple #6
0
def test_table_of_contents_numbered():
    input_page = la.Page(title="My Page")
    input_page["Section One"]["Item A"] = "some text"
    input_page["Section One"]["Item B"] = "more text"
    input_page["Section Two"]["Item C"]["Item D"] = "and more text"
    input_page["Section Two"]["Item C"]["Item E"] = "even more text"

    output_toc = co.table_of_contents(input_page, numbered=True)
    expected_toc = co.Markdown(" 1. [Section One](#section_one-title)\n\t"
                               " 1. [Item A](#item_a-title)\n\t"
                               " 1. [Item B](#item_b-title)\n"
                               " 1. [Section Two](#section_two-title)\n\t"
                               " 1. [Item C](#item_c-title)\n\t\t"
                               " 1. [Item D](#item_d-title)\n\t\t"
                               " 1. [Item E](#item_e-title)")
    assert output_toc == expected_toc
Exemple #7
0
def test_layout_call_list(page_layout, content_list_fn):
    a = la.Page(title="jazz", children=content_list_fn)
    assert a == page_layout
Exemple #8
0
def test_rshift(page_basic_layout):
    page = la.Page(title="Test Page")
    content = "markdown content"
    passthrough = page["Section One"]["Row One"] >> content
    assert passthrough == page_basic_layout["Section One"]["Row One"]
    assert page == page_basic_layout
Exemple #9
0
def test_child_id_maps_to_child():
    page = la.Page()
    page["Section One"]["Row One"] = "markdown content"
    assert page.section_one is page.children[0]
Exemple #10
0
def test_delitem_key_str_error():
    page = la.Page(title="Test Page")
    page["Section One"]["Row One"] = "markdown content"
    page["Section One"]["Row Two"] = "different content"
    with pytest.raises(KeyError):
        del page["Section One"]["Row Three"]
Exemple #11
0
def test_get_item(page_basic_layout):
    page = la.Page(title="Test Page")
    page["Section One"]["Row One"] = "markdown content"
    assert page.section_one.row_one[0] == page_basic_layout[0][0][0]
Exemple #12
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])),
    )
Exemple #13
0
def test_set_column_as_dict_tuple():
    page = la.Page(title="Test Page")
    with pytest.raises(TypeError):
        page["Section One"]["Row One"]["Column One"] = {
            "Column One": "markdown content"
        }, {"Column Two": "markdown content"}
Exemple #14
0
def test_set_item_existing_attr(page_basic_layout):
    page = la.Page(title="Test Page")
    page["Section One"]["Row One"] = "different content"
    page.section_one.row_one = "markdown content"
    assert page == page_basic_layout
Exemple #15
0
def test_set_item_new_str(page_basic_layout):
    page = la.Page(title="Test Page")
    page["Section One"]["Row One"] = "markdown content"
    assert page == page_basic_layout
Exemple #16
0
_irises_path = str(Path("tests/resources/irises.jpg").absolute())
_markdown_path = str(Path("tests/resources/markdown.md").absolute())

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"
Exemple #17
0
def test_delitem_int(page_basic_layout):
    page = la.Page(title="Test Page")
    page["Section One"]["Row One"] = "markdown content"
    page["Section One"]["Row Two"] = "different content"
    del page["Section One"][1]
    assert page == page_basic_layout
Exemple #18
0
def test_delattr(page_basic_layout):
    page = la.Page(title="Test Page")
    page["Section One"]["Row One"] = "markdown content"
    page["Section One"]["Row Two"]["Markdown"] = "different content"
    del page.section_one.row_two
    assert page == page_basic_layout
Exemple #19
0
                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"]),
            ]
        ),
    ),
    (
        la.Section(title="jazz"),
        la.Row(
            children=[
                la.Column(children=["john coltrane"]),
                la.Column(children=["wayne shorter"]),
            ]