-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_setup.py
More file actions
114 lines (99 loc) · 3.02 KB
/
test_setup.py
File metadata and controls
114 lines (99 loc) · 3.02 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
113
114
#!/usr/bin/env python3
"""
Test script to verify KnowledgeOps AI setup
"""
import os
import sys
def test_file_structure():
"""Test that all required files exist"""
required_files = [
'app/__init__.py',
'app/main.py',
'app/config.py',
'app/database.py',
'app/models.py',
'app/logging.py',
'app/metrics.py',
'requirements.txt',
'README.md',
'Dockerfile',
'docker-compose.yml',
'env.example'
]
missing_files = []
for file_path in required_files:
if not os.path.exists(file_path):
missing_files.append(file_path)
if missing_files:
print(f"❌ Missing files: {missing_files}")
return False
else:
print("✅ All required files exist")
return True
def test_imports():
"""Test that Python files can be parsed (without dependencies)"""
python_files = [
'app/__init__.py',
'app/main.py',
'app/config.py',
'app/database.py',
'app/models.py',
'app/logging.py',
'app/metrics.py'
]
for file_path in python_files:
try:
with open(file_path, 'r') as f:
compile(f.read(), file_path, 'exec')
print(f"✅ {file_path} - Syntax OK")
except SyntaxError as e:
print(f"❌ {file_path} - Syntax Error: {e}")
return False
except Exception as e:
print(f"❌ {file_path} - Error: {e}")
return False
return True
def test_requirements():
"""Test requirements.txt format"""
try:
with open('requirements.txt', 'r') as f:
lines = f.readlines()
if len(lines) > 0:
print("✅ requirements.txt has dependencies")
return True
else:
print("❌ requirements.txt is empty")
return False
except Exception as e:
print(f"❌ Error reading requirements.txt: {e}")
return False
def main():
"""Run all tests"""
print("🚀 Testing KnowledgeOps AI Setup")
print("=" * 50)
tests = [
("File Structure", test_file_structure),
("Python Syntax", test_imports),
("Requirements", test_requirements)
]
passed = 0
total = len(tests)
for test_name, test_func in tests:
print(f"\n📋 {test_name}:")
if test_func():
passed += 1
else:
print(f" ❌ {test_name} failed")
print("\n" + "=" * 50)
print(f"📊 Results: {passed}/{total} tests passed")
if passed == total:
print("🎉 All tests passed! KnowledgeOps AI is ready to run.")
print("\nNext steps:")
print("1. Install dependencies: pip install -r requirements.txt")
print("2. Set up environment: cp env.example .env")
print("3. Run the app: python -m app.main")
else:
print("⚠️ Some tests failed. Please check the issues above.")
sys.exit(1)
if __name__ == "__main__":
main()