Skip to content

Commit 5ca854b

Browse files
Merge pull request #244 from adamtheturtle/html-unit
Add unit test for HTML build + PDF
2 parents 5fad40e + 7e7f31d commit 5ca854b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test_integration.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,3 +2093,40 @@ def test_local_pdf_file(
20932093
tmp_path=tmp_path,
20942094
extensions=("sphinx_notion",),
20952095
)
2096+
2097+
2098+
def test_pdf_with_html(
2099+
*,
2100+
make_app: Callable[..., SphinxTestApp],
2101+
tmp_path: Path,
2102+
) -> None:
2103+
"""
2104+
PDF directives with HTML output are processed correctly.
2105+
"""
2106+
rst_content = """
2107+
.. pdf-include:: https://www.example.com/path/to/document.pdf
2108+
"""
2109+
srcdir = tmp_path / "src"
2110+
srcdir.mkdir()
2111+
(srcdir / "conf.py").touch()
2112+
test_pdf_path = srcdir / "test_document.pdf"
2113+
# Create a minimal PDF file (just some dummy data)
2114+
test_pdf_path.write_bytes(data=b"fake pdf content")
2115+
(srcdir / "index.rst").write_text(data=rst_content)
2116+
extensions = ("sphinx_notion", "sphinx_simplepdf")
2117+
app = make_app(
2118+
srcdir=srcdir,
2119+
builddir=tmp_path / "build",
2120+
buildername="html",
2121+
confoverrides={"extensions": list(extensions)},
2122+
)
2123+
app.build()
2124+
assert app.statuscode == 0
2125+
index_html = (tmp_path / "build" / "html" / "index.html").read_text()
2126+
expected_iframe = (
2127+
"<iframe "
2128+
'src="https://www.example.com/path/to/document.pdf" '
2129+
'style="height: 400px; width: 100%">'
2130+
"</iframe>"
2131+
)
2132+
assert expected_iframe in index_html

0 commit comments

Comments
 (0)