From 1ccd0c4fefdb7ec727ba5e5d1648523546a2efaa Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Fri, 9 Feb 2024 17:53:43 +0000 Subject: [PATCH] fix 3.8 and add tests --- src/python-fastui/fastui/__init__.py | 6 ++--- src/python-fastui/tests/test_prebuilt_html.py | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/python-fastui/tests/test_prebuilt_html.py diff --git a/src/python-fastui/fastui/__init__.py b/src/python-fastui/fastui/__init__.py index a2ff3545..8ace8814 100644 --- a/src/python-fastui/fastui/__init__.py +++ b/src/python-fastui/fastui/__init__.py @@ -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/. diff --git a/src/python-fastui/tests/test_prebuilt_html.py b/src/python-fastui/tests/test_prebuilt_html.py new file mode 100644 index 00000000..80314b38 --- /dev/null +++ b/src/python-fastui/tests/test_prebuilt_html.py @@ -0,0 +1,24 @@ +from fastui import prebuilt_html + + +def test_prebuilt_html(): + html = prebuilt_html() + assert html.startswith('') + assert 'https://cdn.jsdelivr.net/npm/@pydantic/fastui-prebuilt' in html + assert '' in html + assert 'Test Title' in html + assert '' in html + assert '' in html + assert '' in html