Spaces:
Sleeping
Sleeping
File size: 6,005 Bytes
2902ce4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
#!/usr/bin/env python3
"""
Test script for TutorX UI/UX enhancements
This script validates the UI improvements and provides a quick way to test the interface.
"""
import sys
import os
import subprocess
import time
from pathlib import Path
def check_dependencies():
"""Check if required dependencies are installed"""
required_packages = [
'gradio',
'matplotlib',
'networkx',
'requests'
]
missing_packages = []
for package in required_packages:
try:
__import__(package)
print(f"β
{package} is installed")
except ImportError:
missing_packages.append(package)
print(f"β {package} is missing")
if missing_packages:
print(f"\nβ οΈ Missing packages: {', '.join(missing_packages)}")
print("Install them with: pip install " + " ".join(missing_packages))
return False
return True
def validate_ui_components():
"""Validate that UI enhancement components are properly implemented"""
print("\nπ Validating UI components...")
try:
# Import the app module to check for syntax errors
sys.path.insert(0, os.getcwd())
import app
# Check if helper functions exist
helper_functions = [
'create_info_card',
'create_status_display',
'create_feature_section'
]
for func_name in helper_functions:
if hasattr(app, func_name):
print(f"β
{func_name} function is available")
else:
print(f"β {func_name} function is missing")
return False
# Check if the main interface function exists
if hasattr(app, 'create_gradio_interface'):
print("β
create_gradio_interface function is available")
else:
print("β create_gradio_interface function is missing")
return False
return True
except Exception as e:
print(f"β Error importing app module: {str(e)}")
return False
def test_interface_creation():
"""Test if the Gradio interface can be created without errors"""
print("\nπ§ͺ Testing interface creation...")
try:
sys.path.insert(0, os.getcwd())
import app
# Try to create the interface
demo = app.create_gradio_interface()
print("β
Gradio interface created successfully")
# Check if demo has the expected properties
if hasattr(demo, 'queue'):
print("β
Interface has queue method")
else:
print("β Interface missing queue method")
return True
except Exception as e:
print(f"β Error creating interface: {str(e)}")
return False
def run_ui_test():
"""Run a quick UI test by launching the interface briefly"""
print("\nπ Running UI test...")
try:
# Launch the app in a subprocess for a brief test
process = subprocess.Popen(
[sys.executable, "app.py"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True
)
# Wait a few seconds to see if it starts successfully
time.sleep(3)
if process.poll() is None:
print("β
UI launched successfully")
process.terminate()
process.wait()
return True
else:
stdout, stderr = process.communicate()
print(f"β UI failed to launch")
if stderr:
print(f"Error: {stderr}")
return False
except Exception as e:
print(f"β Error running UI test: {str(e)}")
return False
def check_documentation():
"""Check if UI/UX documentation exists"""
print("\nπ Checking documentation...")
doc_file = Path("docs/UI_UX_ENHANCEMENTS.md")
if doc_file.exists():
print("β
UI/UX enhancement documentation exists")
# Check file size to ensure it has content
if doc_file.stat().st_size > 1000:
print("β
Documentation has substantial content")
else:
print("β οΈ Documentation file is quite small")
return True
else:
print("β UI/UX enhancement documentation is missing")
return False
def main():
"""Main test function"""
print("π§ TutorX UI/UX Enhancement Test Suite")
print("=" * 50)
tests = [
("Dependencies Check", check_dependencies),
("UI Components Validation", validate_ui_components),
("Interface Creation Test", test_interface_creation),
("Documentation Check", check_documentation),
("UI Launch Test", run_ui_test)
]
results = []
for test_name, test_func in tests:
print(f"\nπ Running: {test_name}")
try:
result = test_func()
results.append((test_name, result))
except Exception as e:
print(f"β Test failed with exception: {str(e)}")
results.append((test_name, False))
# Summary
print("\n" + "=" * 50)
print("π Test Results Summary:")
print("=" * 50)
passed = 0
total = len(results)
for test_name, result in results:
status = "β
PASSED" if result else "β FAILED"
print(f"{test_name}: {status}")
if result:
passed += 1
print(f"\nOverall: {passed}/{total} tests passed")
if passed == total:
print("π All tests passed! UI enhancements are working correctly.")
print("\nπ You can now run the app with: python app.py")
else:
print("β οΈ Some tests failed. Please check the issues above.")
return passed == total
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)
|