Complete independent projection runtime
This commit is contained in:
parent
1134c2d375
commit
f1fabaf0ca
38 changed files with 4907 additions and 87 deletions
|
|
@ -55,6 +55,14 @@ class DocForgeRenderingTests(unittest.TestCase):
|
|||
self.assertEqual("missing", missing["outputs"][0]["state"])
|
||||
|
||||
first = service.render("manual")
|
||||
projection_receipt = first["output"]["projection_receipt"]
|
||||
self.assertIsInstance(projection_receipt, dict)
|
||||
assert isinstance(projection_receipt, dict)
|
||||
self.assertEqual("manual", projection_receipt["kind"])
|
||||
self.assertEqual(
|
||||
first["output"]["actual_output_hash"],
|
||||
projection_receipt["artifacts"][0]["sha256"],
|
||||
)
|
||||
output = root / ".docforge/rendered/manual.html"
|
||||
first_bytes = output.read_bytes()
|
||||
second = service.render("manual")
|
||||
|
|
@ -191,7 +199,12 @@ class DocForgeRenderingTests(unittest.TestCase):
|
|||
self.assertEqual("receipt_corrupt", corrupt["outputs"][0]["reason"])
|
||||
|
||||
def test_render_receipt_schema_and_renderer_version_fail_closed(self) -> None:
|
||||
for mutation in ("missing_hash", "renderer_version", "file_identity"):
|
||||
for mutation in (
|
||||
"missing_hash",
|
||||
"renderer_version",
|
||||
"file_identity",
|
||||
"projection_artifact",
|
||||
):
|
||||
with self.subTest(mutation=mutation), tempfile.TemporaryDirectory() as directory:
|
||||
root = self.copy_fixture("alpha", Path(directory))
|
||||
service = RenderService(Project.open(root))
|
||||
|
|
@ -202,6 +215,8 @@ class DocForgeRenderingTests(unittest.TestCase):
|
|||
receipt.pop("output_hash")
|
||||
elif mutation == "renderer_version":
|
||||
receipt["renderer_version"] = "obsolete"
|
||||
elif mutation == "projection_artifact":
|
||||
receipt["projection_receipt"]["artifacts"][0]["sha256"] = "0" * 64
|
||||
else:
|
||||
receipt["output_file"].pop("ctime_ns")
|
||||
receipt_path.write_text(
|
||||
|
|
@ -401,6 +416,19 @@ class DocForgeRenderingTests(unittest.TestCase):
|
|||
with self.assertRaisesRegex(DocForgeError, "configured limit") as limit_error:
|
||||
limit_service.render("manual")
|
||||
self.assertEqual("render_too_large", limit_error.exception.code)
|
||||
|
||||
excessive = self.copy_fixture("alpha", Path(directory) / "excessive")
|
||||
excessive_descriptor = excessive / ".docforge/project.toml"
|
||||
excessive_descriptor.write_text(
|
||||
excessive_descriptor.read_text(encoding="utf-8").replace(
|
||||
"max_changeset_bytes = 100000",
|
||||
"max_changeset_bytes = 100000\nmax_render_bytes = 20000001",
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
permissive_limit = RenderService(Project.open(excessive)).render("manual")
|
||||
self.assertEqual("current", permissive_limit["receipt"]["state"])
|
||||
self.assertTrue((excessive / ".docforge/rendered/manual.html").is_file())
|
||||
self.assertFalse((limit_root / ".docforge/rendered/manual.html").exists())
|
||||
|
||||
template_limit_root = self.copy_fixture("alpha", parent / "template-limit")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue