- Implement tests for image layer functionality including alpha curve and depth layer behavior. - Create tests for image plane evaluation and modifier input handling. - Add tests to verify the saved asset inventory and its persistence. - Introduce tests for the documentation command to ensure correct project version deployment. - Validate the extension manifest structure and required permissions. - Develop tests for the packaging process, ensuring correct platform handling and dependency management. - Enhance image depth plane group functionality with new split threshold input and surface processing.
89 lines
2.6 KiB
Python
89 lines
2.6 KiB
Python
from tests.support.paths import PROJECT_ROOT
|
|
import importlib.util
|
|
from unittest.mock import patch
|
|
import pytest
|
|
|
|
|
|
SCRIPT_PATH = PROJECT_ROOT / "tools" / "nodes" / "cli.py"
|
|
|
|
|
|
def load_launcher():
|
|
specification = importlib.util.spec_from_file_location(
|
|
"node_asset_launcher",
|
|
SCRIPT_PATH,
|
|
)
|
|
module = importlib.util.module_from_spec(specification)
|
|
specification.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def test_blender_path_prefers_explicit_path(tmp_path):
|
|
launcher = load_launcher()
|
|
executable = tmp_path / "blender"
|
|
executable.touch()
|
|
|
|
with patch.dict("os.environ", {"BLENDER_BIN": "ignored"}):
|
|
assert launcher.blender_path(executable) == executable
|
|
|
|
|
|
def test_blender_path_reads_environment(tmp_path):
|
|
launcher = load_launcher()
|
|
executable = tmp_path / "blender"
|
|
executable.touch()
|
|
|
|
with patch.dict("os.environ", {"BLENDER_BIN": str(executable)}):
|
|
assert launcher.blender_path() == executable
|
|
|
|
|
|
def test_blender_path_reads_project_dotenv(tmp_path):
|
|
launcher = load_launcher()
|
|
executable = tmp_path / "Blender 4.5" / "blender.exe"
|
|
executable.parent.mkdir()
|
|
executable.touch()
|
|
env_path = tmp_path / ".env"
|
|
env_path.write_text(
|
|
f'BLENDER_BIN="{executable}"\n',
|
|
encoding="utf-8",
|
|
)
|
|
|
|
with patch.dict("os.environ", {}, clear=True), patch.object(
|
|
launcher,
|
|
"PROJECT_ROOT",
|
|
tmp_path,
|
|
):
|
|
assert launcher.blender_path() == executable
|
|
|
|
|
|
def test_blender_path_reports_missing_configuration(tmp_path):
|
|
launcher = load_launcher()
|
|
|
|
with patch.dict("os.environ", {}, clear=True), patch.object(
|
|
launcher.shutil,
|
|
"which",
|
|
return_value=None,
|
|
), patch.object(
|
|
launcher,
|
|
"PROJECT_ROOT",
|
|
tmp_path,
|
|
):
|
|
with pytest.raises(RuntimeError, match="Blender not found"):
|
|
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", ["build_nodes"])
|
|
|
|
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")
|