Skip to content

Commit

Permalink
fix 3.8 and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Feb 9, 2024
1 parent 6bbdea0 commit 1ccd0c4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/python-fastui/fastui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def coerce_to_list(cls, v):
def prebuilt_html(
*,
title: str = '',
api_root_url: str | None = None,
api_path_mode: _t.Literal['append', 'query'] | None = None,
api_path_strip: str | None = None,
api_root_url: _t.Union[str, None] = None,
api_path_mode: _t.Union[_t.Literal['append', 'query'], None] = None,
api_path_strip: _t.Union[str, None] = None,
) -> str:
"""
Returns a simple HTML page which includes the FastUI react frontend, loaded from https://www.jsdelivr.com/.
Expand Down
24 changes: 24 additions & 0 deletions src/python-fastui/tests/test_prebuilt_html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from fastui import prebuilt_html


def test_prebuilt_html():
html = prebuilt_html()
assert html.startswith('<!doctype html>')
assert 'https://cdn.jsdelivr.net/npm/@pydantic/fastui-prebuilt' in html
assert '<title></title>' in html
assert '<meta name="fastui:APIRootUrl"' not in html
assert '<meta name="fastui:APIPathMode"' not in html
assert '<meta name="fastui:APIPathStrip"' not in html


def test_prebuilt_html_meta_tags():
html = prebuilt_html(
title='Test Title',
api_root_url='/admin/api',
api_path_mode='query',
api_path_strip='/admin',
)
assert '<title>Test Title</title>' in html
assert '<meta name="fastui:APIRootUrl" content="/admin/api" />' in html
assert '<meta name="fastui:APIPathMode" content="query" />' in html
assert '<meta name="fastui:APIPathStrip" content="/admin" />' in html

0 comments on commit 1ccd0c4

Please sign in to comment.