-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_setup.py
More file actions
90 lines (74 loc) · 2.31 KB
/
test_setup.py
File metadata and controls
90 lines (74 loc) · 2.31 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
#!/usr/bin/env python3
"""
SignalTap Setup Test Script
This script tests that all dependencies are properly installed and the application can be imported.
"""
import sys
import importlib
def test_imports():
"""Test that all required packages can be imported"""
required_packages = [
'fastapi',
'uvicorn',
'pylogix',
'pydantic',
'python-dotenv'
]
print("🔍 Testing package imports...")
for package in required_packages:
try:
importlib.import_module(package)
print(f"✅ {package} - OK")
except ImportError as e:
print(f"❌ {package} - FAILED: {e}")
return False
return True
def test_app_imports():
"""Test that our application modules can be imported"""
app_modules = [
'app.main',
'app.routes.plc',
'app.services.pylogix_service',
'app.models.tag'
]
print("\n🔍 Testing application imports...")
for module in app_modules:
try:
importlib.import_module(module)
print(f"✅ {module} - OK")
except ImportError as e:
print(f"❌ {module} - FAILED: {e}")
return False
return True
def test_fastapi_app():
"""Test that the FastAPI app can be created"""
try:
from app.main import app
print("✅ FastAPI app creation - OK")
return True
except Exception as e:
print(f"❌ FastAPI app creation - FAILED: {e}")
return False
def main():
"""Run all tests"""
print("🚀 SignalTap Setup Test")
print("=" * 40)
# Test package imports
if not test_imports():
print("\n❌ Package import test failed!")
sys.exit(1)
# Test app imports
if not test_app_imports():
print("\n❌ Application import test failed!")
sys.exit(1)
# Test FastAPI app
if not test_fastapi_app():
print("\n❌ FastAPI app test failed!")
sys.exit(1)
print("\n🎉 All tests passed! SignalTap is ready to run.")
print("\n📖 Next steps:")
print("1. Run './run.sh' (Linux/macOS) or 'run.bat' (Windows)")
print("2. Open http://localhost:8000/docs in your browser")
print("3. Test the API endpoints with your PLC")
if __name__ == "__main__":
main()