-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_import.py
More file actions
141 lines (121 loc) · 4.41 KB
/
test_import.py
File metadata and controls
141 lines (121 loc) · 4.41 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
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
#!/usr/bin/env python3
"""
Test script to verify if all required dependencies are installed
and if the Instagram Automation Tool can be imported and initialized correctly.
"""
import sys
import json
import os
def test_imports():
"""Test importing all required packages."""
missing_packages = []
# Test essential packages
essential_packages = [
"requests",
"dotenv",
"pydantic",
"selenium",
"webdriver_manager",
"tqdm",
"colorama"
]
print("Testing essential packages:")
for package in essential_packages:
try:
if package == "dotenv":
# python-dotenv is imported as dotenv
__import__("dotenv")
else:
__import__(package)
print(f" ✓ {package}")
except ImportError:
missing_packages.append(package)
print(f" ✗ {package}")
# Test agency-swarm
print("\nTesting agency-swarm:")
try:
import agency_swarm
print(" ✓ agency_swarm")
print(f" Version: {getattr(agency_swarm, '__version__', 'unknown')}")
print(f" Path: {agency_swarm.__file__}")
except ImportError:
missing_packages.append("agency_swarm")
print(" ✗ agency_swarm")
# Report results
if missing_packages:
print("\nMissing packages:")
for package in missing_packages:
print(f" - {package}")
return False
else:
print("\nAll required packages are installed!")
return True
def test_instagram_automation_tool():
"""Test importing and initializing the Instagram Automation Tool."""
print("\nTesting Instagram Automation Tool:")
try:
# Test importing the tool
print(" Testing import...")
try:
# Try importing from the package first (recommended)
from instagram_automation_tool import InstagramAutomationTool
except ImportError:
# Fallback to direct import from the file
from instagram_automation_tool_improved import InstagramAutomationTool
print(" ✓ Import successful")
# Test initializing the tool
print(" Testing initialization...")
tool = InstagramAutomationTool()
print(" ✓ Initialization successful")
# Test if agency setup works correctly
print(" Testing agency setup...")
agency = tool.agency
# Check if all required agents are present
required_agents = [
"AccountManagerAgent",
"MessagingAgent",
"ContentPosterAgent",
"BrowserManagerAgent"
]
for agent_name in required_agents:
agent = agency.get_agent(agent_name)
if agent:
print(f" ✓ Agent found: {agent_name}")
else:
print(f" ✗ Agent not found: {agent_name}")
return False
# Test configuration loading
print("\nTesting configuration loading:")
if tool.config:
print(f" ✓ Configuration loaded successfully")
print(f" Database type: {tool.config.get('database', {}).get('type', 'unknown')}")
else:
print(f" ✗ Configuration loading failed")
return False
# Test database initialization
print("\nTesting database initialization:")
if tool.db:
print(f" ✓ Database initialized successfully")
print(f" Database path: {tool.db.db_path}")
# Verify database path
expected_path = "data/database.json"
if tool.db.db_path != expected_path:
print(f" ✗ Database path mismatch: expected '{expected_path}', got '{tool.db.db_path}'")
return False
else:
print(f" ✓ Database path is correct: {tool.db.db_path}")
else:
print(f" ✗ Database initialization failed")
return False
return True
except Exception as e:
print(f" ✗ Error: {str(e)}")
return False
if __name__ == "__main__":
imports_success = test_imports()
if imports_success:
tool_success = test_instagram_automation_tool()
success = imports_success and tool_success
else:
success = False
sys.exit(0 if success else 1)