Files
dvc/tests/unit/render/test_html.py
T
David de la Iglesia Castroandpre-commit-ci[bot] e5cf9b203d Add auto-refresh option to html (#6400)
* Added refresh tag

* Formatted

* Added refresh_seconds to live

* Added refresh test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Add refresh_seconds to render

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update html.py

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2021-09-01 17:17:23 +08:00

48 lines
1.1 KiB
Python

import pytest
from dvc.render.html import HTML, PAGE_HTML, MissingPlaceholderError
CUSTOM_PAGE_HTML = """<!DOCTYPE html>
<html>
<head>
<title>TITLE</title>
<script type="text/javascript" src="vega"></script>
<script type="text/javascript" src="vega-lite"></script>
<script type="text/javascript" src="vega-embed"></script>
</head>
<body>
{plot_divs}
</body>
</html>"""
@pytest.mark.parametrize(
"template,page_elements,expected_page",
[
(
None,
["content"],
PAGE_HTML.format(plot_divs="content", refresh_tag=""),
),
(
CUSTOM_PAGE_HTML,
["content"],
CUSTOM_PAGE_HTML.format(plot_divs="content"),
),
],
)
def test_html(tmp_dir, template, page_elements, expected_page):
page = HTML(template)
page.elements = page_elements
result = page.embed()
assert result == expected_page
def test_no_placeholder(tmp_dir):
template = "<head></head><body></body>"
with pytest.raises(MissingPlaceholderError):
HTML(template)