Add new functionality for image rectification and depth metadata handling
- Implemented a preview tool for rectifying images with interactive aspect controls in `preview.py`. - Added tests for depth metadata loading to ensure consistent schema usage in `test_depth_metadata.py`. - Developed comprehensive tests for cutout calibration processes in `test_cutout_calibration.py`, including stability checks and depth calibration. - Created tests for frame compositing operations in `test_frame_compositing.py`, ensuring correct handling of depth and transparency. - Introduced material slot inheritance functionality in `material_slots.py` to manage geometry material assignments. - Built shared shader nodes for material processing in `shader.py`, including roughness and bump mapping setups.
This commit is contained in:
@@ -70,69 +70,31 @@ def test_blender_path_reports_missing_configuration(tmp_path):
|
||||
launcher.blender_path()
|
||||
|
||||
|
||||
def test_launcher_runs_asset_build_and_validations_before_tests(monkeypatch, tmp_path):
|
||||
launcher = load_launcher()
|
||||
executable = tmp_path / "blender"
|
||||
executable.touch()
|
||||
calls = []
|
||||
monkeypatch.setattr(launcher, "blender_path", lambda _: executable)
|
||||
monkeypatch.setattr(launcher, "run", calls.append)
|
||||
monkeypatch.setattr("sys.argv", ["node-group", "build"])
|
||||
|
||||
launcher.main()
|
||||
|
||||
assert len(calls) == 3
|
||||
assert "runpy.run_module('tools.nodes.build', run_name='__main__')" in calls[0][-1]
|
||||
assert "runpy.run_module('tools.nodes.check', run_name='__main__')" in calls[1][-1]
|
||||
assert all(command[1:6] == ("--factory-startup", "--background", "--python-exit-code", "1", "--python-expr") for command in calls[:-1])
|
||||
assert calls[-1][1:] == ("-m", "pytest")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("skip_tests", [False, True])
|
||||
def test_check_validates_without_building(monkeypatch, skip_tests):
|
||||
launcher = load_launcher()
|
||||
calls = []
|
||||
monkeypatch.setattr(launcher, "blender_path", lambda _: "blender")
|
||||
monkeypatch.setattr(launcher, "run", calls.append)
|
||||
monkeypatch.setattr("sys.argv", ["node-group", "check", *(["--skip-tests"] if skip_tests else [])])
|
||||
launcher.main()
|
||||
assert len(calls) == (1 if skip_tests else 2)
|
||||
assert "tools.nodes.check" in calls[0][-1]
|
||||
assert "tools.nodes.build" not in calls[0][-1]
|
||||
|
||||
|
||||
def test_build_stops_after_blender_failure(monkeypatch):
|
||||
launcher = load_launcher()
|
||||
monkeypatch.setattr(launcher, "blender_path", lambda _: "blender")
|
||||
monkeypatch.setattr("sys.argv", ["node-group", "build"])
|
||||
with patch.object(launcher, "run", side_effect=RuntimeError("failed")) as run:
|
||||
with pytest.raises(RuntimeError, match="failed"):
|
||||
launcher.main()
|
||||
assert run.call_count == 1
|
||||
|
||||
|
||||
@pytest.mark.parametrize("arguments,opens", [([], True), (["--no-open"], False), (["--fragment"], False)])
|
||||
def test_preview_passes_isolated_arguments_and_opens_result(monkeypatch, tmp_path, arguments, opens):
|
||||
@pytest.mark.parametrize("arguments,modules,run_tests", [
|
||||
(["build"], ("tools.nodes.build", "tools.nodes.check"), True),
|
||||
(["check", "--skip-tests"], ("tools.nodes.check",), False),
|
||||
(["preview", "--fragment"], ("tools.nodes.preview.export",), False),
|
||||
])
|
||||
def test_commands_dispatch_requested_work(monkeypatch, tmp_path, arguments, modules, run_tests):
|
||||
launcher = load_launcher()
|
||||
output = tmp_path / "node groups.html"
|
||||
calls = []
|
||||
command = ["node-group", *arguments]
|
||||
if arguments[0] == "preview":
|
||||
command += ["--output", str(output)]
|
||||
monkeypatch.setattr("sys.argv", command)
|
||||
monkeypatch.setattr(launcher, "blender_path", lambda _: "blender")
|
||||
monkeypatch.setattr(launcher, "run", calls.append)
|
||||
monkeypatch.setattr("sys.argv", ["node-group", "preview", "--output", str(output), *arguments])
|
||||
with patch.object(launcher.webbrowser, "open") as open_browser:
|
||||
with (
|
||||
patch.object(launcher, "run_blender_modules") as blender,
|
||||
patch.object(launcher, "run") as run,
|
||||
patch.object(launcher.webbrowser, "open") as open_browser,
|
||||
):
|
||||
launcher.main()
|
||||
assert len(calls) == 1
|
||||
expression = calls[0][-1]
|
||||
import ast
|
||||
assignment = next(
|
||||
node for node in ast.parse(expression).body
|
||||
if isinstance(node, ast.Assign) and ast.unparse(node.targets[0]) == "sys.argv"
|
||||
)
|
||||
assert ast.literal_eval(assignment.value) == [
|
||||
"tools.nodes.preview.export", "--output", str(output),
|
||||
*(["--fragment"] if "--fragment" in arguments else []),
|
||||
]
|
||||
if opens:
|
||||
open_browser.assert_called_once_with(output.as_uri())
|
||||
else:
|
||||
if arguments[0] == "preview":
|
||||
blender.assert_called_once_with("blender", modules, ["--output", str(output), "--fragment"])
|
||||
open_browser.assert_not_called()
|
||||
else:
|
||||
blender.assert_called_once_with("blender", modules)
|
||||
if run_tests:
|
||||
run.assert_called_once_with((launcher.sys.executable, "-m", "pytest"))
|
||||
else:
|
||||
run.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user