-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_ui.py
More file actions
112 lines (93 loc) · 3.09 KB
/
test_ui.py
File metadata and controls
112 lines (93 loc) · 3.09 KB
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
"""
Test script to validate the Streamlit app structure
This tests that app.py can be imported and has the required components
"""
import sys
def test_app_import():
"""Test that app.py can be imported"""
print("🧪 Testing app.py import...")
try:
import app
print(" ✅ app.py imports successfully")
return True
except ImportError as e:
print(f" ❌ Import failed: {e}")
return False
def test_app_functions():
"""Test that required functions exist in app.py"""
print("\n🧪 Testing app.py functions...")
try:
import app
# Check for key functions
required_functions = [
'load_api_key',
'initialize_session_state',
'display_header',
'display_sidebar',
'run_creative_workflow',
'display_results',
'main'
]
for func_name in required_functions:
if not hasattr(app, func_name):
print(f" ❌ Missing function: {func_name}")
return False
print(" ✅ All required functions exist")
return True
except Exception as e:
print(f" ❌ Function test failed: {e}")
return False
def test_streamlit_import():
"""Test that Streamlit is installed and can be imported"""
print("\n🧪 Testing Streamlit installation...")
try:
import streamlit as st
print(f" ✅ Streamlit version {st.__version__} installed")
return True
except ImportError as e:
print(f" ❌ Streamlit import failed: {e}")
return False
def test_creative_studio_import():
"""Test that CreativeStudio can still be imported from main.py"""
print("\n🧪 Testing CreativeStudio import from main.py...")
try:
from main import CreativeStudio
print(" ✅ CreativeStudio imports successfully from main.py")
print(" ✅ CLI functionality remains intact")
return True
except ImportError as e:
print(f" ❌ CreativeStudio import failed: {e}")
return False
def main():
"""Run all validation tests"""
print("=" * 80)
print("🎨 STREAMLIT WEB UI - VALIDATION TESTS")
print("=" * 80)
tests = [
test_streamlit_import,
test_app_import,
test_app_functions,
test_creative_studio_import
]
results = []
for test in tests:
results.append(test())
print("\n" + "=" * 80)
print("📊 TEST SUMMARY")
print("=" * 80)
passed = sum(results)
total = len(results)
print(f"Tests passed: {passed}/{total}")
if passed == total:
print("✅ All validation tests passed!")
print("\n💡 The Streamlit web UI is ready to use.")
print("📝 To run the web UI:")
print(" streamlit run app.py")
print("\n📝 To run the CLI (still works):")
print(" python main.py 'your topic here'")
return 0
else:
print("❌ Some tests failed. Please check the errors above.")
return 1
if __name__ == "__main__":
sys.exit(main())