167 lines
5.6 KiB
Python
167 lines
5.6 KiB
Python
"""
|
|
Test UI Folder Selection
|
|
|
|
Simple test to verify that the folder selection UI works correctly
|
|
for the assets_folder property in multi-series mode.
|
|
|
|
Usage:
|
|
python test_ui_folder_selection.py
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# Add project root to path
|
|
project_root = Path(__file__).parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
try:
|
|
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget, QLabel
|
|
from PyQt5.QtCore import Qt
|
|
PYQT_AVAILABLE = True
|
|
except ImportError:
|
|
PYQT_AVAILABLE = False
|
|
|
|
def test_folder_selection_ui():
|
|
"""Test the folder selection UI components"""
|
|
|
|
if not PYQT_AVAILABLE:
|
|
print("❌ PyQt5 not available, cannot test UI components")
|
|
return False
|
|
|
|
try:
|
|
from core.nodes.exact_nodes import ExactModelNode, NODEGRAPH_AVAILABLE
|
|
|
|
if not NODEGRAPH_AVAILABLE:
|
|
print("❌ NodeGraphQt not available, cannot test node properties UI")
|
|
return False
|
|
|
|
# Create QApplication
|
|
app = QApplication(sys.argv) if not QApplication.instance() else QApplication.instance()
|
|
|
|
# Create test node
|
|
node = ExactModelNode()
|
|
|
|
# Enable multi-series mode
|
|
node.set_property('multi_series_mode', True)
|
|
|
|
# Test property access
|
|
assets_folder = node.get_property('assets_folder')
|
|
enabled_series = node.get_property('enabled_series')
|
|
|
|
print(f"✅ Node created successfully")
|
|
print(f" - assets_folder: '{assets_folder}'")
|
|
print(f" - enabled_series: {enabled_series}")
|
|
print(f" - multi_series_mode: {node.get_property('multi_series_mode')}")
|
|
|
|
# Get property options
|
|
property_options = node._property_options
|
|
assets_folder_options = property_options.get('assets_folder', {})
|
|
enabled_series_options = property_options.get('enabled_series', {})
|
|
|
|
print(f"✅ Property options configured correctly")
|
|
print(f" - assets_folder type: {assets_folder_options.get('type')}")
|
|
print(f" - enabled_series type: {enabled_series_options.get('type')}")
|
|
print(f" - enabled_series options: {enabled_series_options.get('options')}")
|
|
|
|
# Test display properties
|
|
display_props = node.get_display_properties()
|
|
print(f"✅ Display properties for multi-series mode: {display_props}")
|
|
|
|
# Verify multi-series specific properties are included
|
|
expected_props = ['assets_folder', 'enabled_series']
|
|
missing_props = [prop for prop in expected_props if prop not in display_props]
|
|
|
|
if missing_props:
|
|
print(f"❌ Missing properties in display: {missing_props}")
|
|
return False
|
|
|
|
print(f"✅ All multi-series properties present in UI")
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"❌ Test failed: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
def create_test_assets_folder():
|
|
"""Create a test assets folder for UI testing"""
|
|
try:
|
|
from utils.multi_series_setup import MultiSeriesSetup
|
|
|
|
test_path = os.path.join(project_root, "test_ui_assets")
|
|
|
|
# Remove existing test folder
|
|
if os.path.exists(test_path):
|
|
import shutil
|
|
shutil.rmtree(test_path)
|
|
|
|
# Create new test structure
|
|
success = MultiSeriesSetup.create_folder_structure(
|
|
project_root.parent, # Create in parent directory to avoid clutter
|
|
series_list=['520', '720']
|
|
)
|
|
|
|
if success:
|
|
assets_path = os.path.join(project_root.parent, "Assets")
|
|
print(f"✅ Test assets folder created: {assets_path}")
|
|
print("📋 You can now:")
|
|
print("1. Run your UI application")
|
|
print("2. Create a Model Node")
|
|
print("3. Enable 'Multi-Series Mode'")
|
|
print("4. Use 'Browse Folder' button for 'Assets Folder'")
|
|
print(f"5. Select the folder: {assets_path}")
|
|
return assets_path
|
|
else:
|
|
print("❌ Failed to create test assets folder")
|
|
return None
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error creating test assets: {e}")
|
|
return None
|
|
|
|
def main():
|
|
"""Main test function"""
|
|
print("🧪 Testing UI Folder Selection for Multi-Series Configuration\n")
|
|
|
|
# Test 1: Node property configuration
|
|
print("=" * 50)
|
|
print("Test 1: Node Property Configuration")
|
|
print("=" * 50)
|
|
|
|
success = test_folder_selection_ui()
|
|
|
|
if not success:
|
|
print("❌ UI component test failed")
|
|
return False
|
|
|
|
# Test 2: Create test assets folder
|
|
print("\n" + "=" * 50)
|
|
print("Test 2: Create Test Assets Folder")
|
|
print("=" * 50)
|
|
|
|
assets_path = create_test_assets_folder()
|
|
|
|
if assets_path:
|
|
print("\n🎉 UI folder selection test completed successfully!")
|
|
print("\n📋 Manual Testing Steps:")
|
|
print("1. Run: python main.py")
|
|
print("2. Create a new pipeline")
|
|
print("3. Add a Model Node")
|
|
print("4. In properties panel, enable 'Multi-Series Mode'")
|
|
print("5. Click 'Browse Folder' for 'Assets Folder'")
|
|
print(f"6. Select folder: {assets_path}")
|
|
print("7. Configure 'Enabled Series' checkboxes")
|
|
print("8. Save and deploy pipeline")
|
|
|
|
return True
|
|
else:
|
|
print("❌ Test assets creation failed")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
success = main()
|
|
sys.exit(0 if success else 1) |