Skip to content

Commit

Permalink
Test if materials are still working after reloading blend file
Browse files Browse the repository at this point in the history
  • Loading branch information
30350n committed May 17, 2023
1 parent 3c2e73e commit 24dbacb
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from itertools import product, chain
from pathlib import Path
from tempfile import gettempdir

import pytest

test_filepaths = (Path(__file__).parent / "test_pcbs").resolve().glob("**/*.pcb3d")
test_filepaths = list((Path(__file__).parent / "test_pcbs").resolve().glob("**/*.pcb3d"))

kwargs_test_permutations = {
"import_components": (True, False),
Expand Down Expand Up @@ -41,3 +42,21 @@ def test_importer(path, kwargs):
assert result == {"FINISHED"}
assert len(bpy.context.view_layer.objects) > 0
assert bpy.context.object != None

def test_load_file():
test_path = str(Path(gettempdir()) / "pcb2blender_test.blend")

bpy.ops.wm.read_homefile(use_empty=True)
bpy.ops.pcb2blender.import_pcb3d(filepath=str(test_filepaths[0]))
bpy.ops.wm.save_mainfile(filepath=test_path)

assert not has_undefined_nodes()

bpy.ops.wm.read_homefile(use_empty=True)
bpy.ops.wm.open_mainfile(filepath=test_path)

assert not has_undefined_nodes()

def has_undefined_nodes():
node_groups = (group for group in bpy.data.node_groups if group.type == "SHADER")
return "NodeUndefined" in (node.bl_idname for group in node_groups for node in group.nodes)

0 comments on commit 24dbacb

Please sign in to comment.