75 lines
2.6 KiB
Python
75 lines
2.6 KiB
Python
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.append(str(PROJECT_ROOT.parent))
|
|
sys.path.append(str(PROJECT_ROOT))
|
|
|
|
# Define dummy classes to avoid metaclass conflicts
|
|
class DummyNodeSocket: pass
|
|
class DummyNode: pass
|
|
class DummyObject: pass
|
|
class DummyMesh: pass
|
|
class DummyNodeSocketShader: pass
|
|
class DummyNodeCustomGroup: pass
|
|
class DummyNodeTree: pass
|
|
class DummyOperator: pass
|
|
class DummyMenu: pass
|
|
class DummyPanel: pass
|
|
class DummyPropertyGroup: pass
|
|
|
|
from unittest.mock import MagicMock
|
|
mock_types = MagicMock()
|
|
mock_types.NodeSocket = DummyNodeSocket
|
|
mock_types.Node = DummyNode
|
|
mock_types.Object = DummyObject
|
|
mock_types.Mesh = DummyMesh
|
|
mock_types.NodeSocketShader = DummyNodeSocketShader
|
|
mock_types.NodeCustomGroup = DummyNodeCustomGroup
|
|
mock_types.NodeTree = DummyNodeTree
|
|
mock_types.Operator = DummyOperator
|
|
mock_types.Menu = DummyMenu
|
|
mock_types.Panel = DummyPanel
|
|
mock_types.PropertyGroup = DummyPropertyGroup
|
|
|
|
mock_bpy = MagicMock()
|
|
mock_bpy.context.scene = MagicMock()
|
|
mock_bpy.context.scene.unit_settings.scale_length = 0.001
|
|
mock_bpy.types = mock_types
|
|
|
|
sys.modules['bpy'] = mock_bpy
|
|
sys.modules['bpy.types'] = mock_types
|
|
sys.modules['bpy.props'] = MagicMock()
|
|
sys.modules['bpy.utils'] = MagicMock()
|
|
sys.modules['bpy.utils.previews'] = MagicMock()
|
|
sys.modules['bpy.app'] = MagicMock()
|
|
sys.modules['bpy.app.handlers'] = MagicMock()
|
|
|
|
import unittest
|
|
from NodeSlicer.tests.visual.visualize_path_operations import run_all_visualizations, OUTPUT_DIR, IMAGES_DIR
|
|
|
|
class TestVisualOperations(unittest.TestCase):
|
|
def test_run_all_visual_path_operations(self):
|
|
results = run_all_visualizations()
|
|
self.assertGreater(len(results), 0)
|
|
|
|
# Ensure index.html exists and has content
|
|
index_html = os.path.join(OUTPUT_DIR, "index.html")
|
|
self.assertTrue(os.path.exists(index_html))
|
|
self.assertGreater(os.path.getsize(index_html), 100)
|
|
|
|
# Ensure README.md exists and has content
|
|
readme_md = os.path.join(OUTPUT_DIR, "README.md")
|
|
self.assertTrue(os.path.exists(readme_md))
|
|
self.assertGreater(os.path.getsize(readme_md), 100)
|
|
|
|
# Ensure every image file exists and is non-empty, and status is PASS
|
|
for r in results:
|
|
self.assertEqual(r["status"], "PASS", f"Test {r['id']} ({r['title']}) failed")
|
|
img_path = os.path.join(IMAGES_DIR, r["image"])
|
|
self.assertTrue(os.path.exists(img_path), f"Image {img_path} not found")
|
|
self.assertGreater(os.path.getsize(img_path), 1000, f"Image {img_path} is too small")
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|