improve back and frontend testing

This commit is contained in:
2026-03-29 19:58:06 -07:00
parent 29eee8a42c
commit e9215a64ff
70 changed files with 13441 additions and 134 deletions

View File

@@ -27,3 +27,31 @@ def test_mask_morphology():
dilated_disk, = node.process(mask, operation="dilate", radius=2, shape="disk")
assert np.count_nonzero(dilated_disk) > orig_count
def test_mask_morphology_with_field():
from backend.nodes.mask_morphology import MaskMorphology
from backend.execution_context import active_node, execution_callbacks
from tests.node_tests._shared import make_field
node = MaskMorphology()
mask = np.zeros((32, 32), dtype=np.uint8)
mask[10:22, 10:22] = 255
field = make_field(data=np.ones((32, 32)))
previews = []
with execution_callbacks(preview=lambda nid, d: previews.append(d)), active_node("test"):
dilated, = node.process(mask, operation="dilate", radius=1, shape="square", field=field)
assert dilated.dtype == np.uint8
assert len(previews) == 1
def test_mask_morphology_unknown_operation():
from backend.nodes.mask_morphology import MaskMorphology
node = MaskMorphology()
mask = np.zeros((32, 32), dtype=np.uint8)
try:
node.process(mask, operation="invalid_op", radius=1, shape="square")
assert False, "Expected ValueError"
except ValueError:
pass