async def kiosk(): html = await render_template_string( open( safe_join(os.path.dirname(kiosk_module.__file__), 'index.html'), 'r').read(), bundle_url='/kiosk/kiosk.js', configuration=json.dumps({ 'websockets_url_path': '/ws', 'space_state_url': '/space_state', }), ) return Response(html.encode('utf-8'), mimetype='text/html; charset=utf-8')
def test_safe_join_raises(paths: List[str], tmpdir: LocalPath) -> None: directory = tmpdir.mkdir("safe").realpath() tmpdir.mkdir("other") tmpdir.mkdir("safes").join("file").write("something") with pytest.raises(NotFound): safe_join(directory, *paths)
def test_safe_join(tmpdir: LocalPath) -> None: directory = tmpdir.realpath() tmpdir.join("file.txt").write("something") assert safe_join(directory, "file.txt") == Path(directory, "file.txt")
async def kiosk_bundle(): return await send_file( safe_join(os.path.dirname(kiosk_module.__file__), 'kiosk_bundle.js'))
def test_safe_join_raises(directory: str, paths: List[str]) -> None: with pytest.raises(NotFound): safe_join(directory, *paths)
def test_safe_join(directory: str, paths: List[str], expected: Path) -> None: assert safe_join(directory, *paths) == expected