Пример #1
0
def test_write_pages(scratch, tmpdir):
    Page()
    app = Application()
    app.write(folder=tmpdir)
    html_file = tmpdir.join("_.html")
    with open(html_file) as f:
        html = f.read()
    assert html == str(Page._dict['/'].html())
Пример #2
0
def test_assign_orphan_already_home(scratch):
    Page()
    Widget()
    Widget()

    Application().assign_orphan_widgets()

    assert "/" in Page._dict
    assert len(Page._dict["/"].widgets) == 2
Пример #3
0
def test_assign_only_orphan(scratch):
    w1 = Widget()
    w2 = Widget()

    Application().assign_orphan_widgets()

    assert "/" in Page._dict
    assert Page._dict["/"].widgets[0] is w1
    assert Page._dict["/"].widgets[1] is w2
Пример #4
0
def test_assign_orphan(scratch):
    w1 = Widget()
    w2 = Widget()
    w3 = Widget()
    p = Page("/test")
    p.add(w2)

    Application().assign_orphan_widgets()

    assert "/" in Page._dict and "/test" in Page._dict
    assert Page._dict["/"].widgets[0] is w1
    assert Page._dict["/test"].widgets[0] is w2
    assert Page._dict["/"].widgets[1] is w3
Пример #5
0
def test_define_route_with_callbacks(scratch):
    app = Application()
    app.files = {}
    app.callbacks = {1: "test"}
    app.define_routes()

    fapi_routes = [route.path for route in app.fapi.routes]
    assert "/callback/{callback_id}" in fapi_routes
Пример #6
0
def test_define_route(scratch, routes):
    app = Application()
    app.files = {r: "whatever.html" for r in routes}
    app.callbacks = {}
    app.define_routes()

    fapi_routes = [route.path for route in app.fapi.routes]
    for r in routes:
        assert r in fapi_routes
Пример #7
0
def test_assign_empty(scratch):
    Application().assign_orphan_widgets()

    assert "/" in Page._dict
    assert len(Page._dict["/"].widgets) == 0
Пример #8
0
Header(level=5, center=True)
Header(level=6, center=True)

Markdown("""# Title 1
## Title 2

Markdown.
Markdown.

This is a list :
* Element 1
* Element 2

Normal text
**Bold text**
*Italic text*
_Italic text_

---

Horizontal ruler.

Code `inside` the line.

```python
Full code
```""")

if __name__ == "__main__":
    Application().serve()