from pathlib import Path from pytest import mark, raises from jweb.content import Content from jweb.context import Context @mark.parametrize("content", ["# Otters", b"# Otters"]) def test_load(datadir: Path, content: bytes | str) -> None: context = Context(datadir) context.load_extensions("jweb.extensions.markdown") context.render("test-load.html", "output.html", content=Content(Path("content.yml"), content, None)) with open(datadir / "build" / "output.html", encoding="utf-8") as ouput_file: assert ouput_file.read() == "

Otters

" def test_load_type_error(datadir: Path) -> None: context = Context(datadir) context.load_extensions("jweb.extensions.markdown") with raises(ValueError): context.render("test-load.html", "output.html", content=Content(Path("content.yml"), 10, None)) with raises(ValueError): context.render("test-load.html", "output.html", content=10) def test_metadata(datadir: Path) -> None: context = Context(datadir) context.load_extensions("jweb.extensions.markdown") markdown = "---\n" "title: Steven\n" "---\n" "\n" "Content\n" context.render("test-metadata.html", "output.html", content=Content(Path("content.yml"), markdown, None)) with open(datadir / "build" / "output.html", encoding="utf-8") as ouput_file: assert ouput_file.read() == "Steven"