-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_app.py
More file actions
168 lines (136 loc) · 4.55 KB
/
test_app.py
File metadata and controls
168 lines (136 loc) · 4.55 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
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
#!/usr/bin/env python3
"""
Basic tests for the dual-platform video uploader
NoblePort Systems
"""
def test_config():
"""Test configuration module"""
print("Testing configuration...")
from config import Config, CopyrightPolicy
# Test Config
assert Config.UPLOAD_FOLDER is not None
assert Config.MAX_FILE_SIZE > 0
print(" ✓ Config class loaded")
# Test CopyrightPolicy
comparison = CopyrightPolicy.get_comparison()
assert 'youtube' in comparison
assert 'dtube' in comparison
assert 'summary' in comparison
print(" ✓ Copyright policies loaded")
# Test YouTube policy
yt = CopyrightPolicy.YOUTUBE
assert yt['name'] == 'YouTube'
assert yt['risk_level'] == 'HIGH'
assert yt['automated_scanning'] == True
print(" ✓ YouTube policy correct")
# Test DTube policy
dt = CopyrightPolicy.DTUBE
assert dt['name'] == 'DTube'
assert dt['risk_level'] == 'LOW'
assert dt['automated_scanning'] == False
print(" ✓ DTube policy correct")
print("Configuration tests passed!\n")
def test_youtube_uploader():
"""Test YouTube uploader module"""
print("Testing YouTube uploader...")
from youtube_uploader import YouTubeUploader, YOUTUBE_CATEGORIES
# Test initialization
uploader = YouTubeUploader()
assert uploader is not None
print(" ✓ YouTubeUploader initialized")
# Test warnings
warnings = uploader.get_copyright_warnings()
assert warnings['platform'] == 'youtube'
assert len(warnings['warnings']) > 0
print(" ✓ Copyright warnings available")
# Test categories
assert len(YOUTUBE_CATEGORIES) > 0
assert '22' in YOUTUBE_CATEGORIES
print(" ✓ Categories loaded")
print("YouTube uploader tests passed!\n")
def test_dtube_uploader():
"""Test DTube uploader module"""
print("Testing DTube uploader...")
from dtube_uploader import DtubeUploader
# Test initialization
uploader = DtubeUploader()
assert uploader is not None
print(" ✓ DtubeUploader initialized")
# Test warnings
warnings = uploader.get_copyright_warnings()
assert warnings['platform'] == 'dtube'
assert len(warnings['warnings']) > 0
print(" ✓ Copyright warnings available")
# Test permlink generation
permlink = uploader._generate_permlink("Test Video Title")
assert 'test-video-title' in permlink
print(" ✓ Permlink generation works")
print("DTube uploader tests passed!\n")
def test_flask_app():
"""Test Flask application"""
print("Testing Flask app...")
from app import app
# Test app exists
assert app is not None
print(" ✓ Flask app initialized")
# Test routes
with app.test_client() as client:
# Test health endpoint
response = client.get('/health')
assert response.status_code == 200
data = response.get_json()
assert data['status'] == 'healthy'
print(" ✓ Health endpoint works")
# Test copyright policies endpoint
response = client.get('/api/copyright-policies')
assert response.status_code == 200
data = response.get_json()
assert 'youtube' in data
assert 'dtube' in data
print(" ✓ Copyright policies API works")
# Test platform info endpoint
response = client.get('/api/platform-info/youtube')
assert response.status_code == 200
data = response.get_json()
assert data['name'] == 'YouTube'
print(" ✓ Platform info API works")
print("Flask app tests passed!\n")
def main():
"""Run all tests"""
print("="*60)
print(" Dual-Platform Video Uploader - Test Suite")
print(" NoblePort Systems")
print("="*60)
print()
try:
test_config()
test_youtube_uploader()
test_dtube_uploader()
test_flask_app()
print("="*60)
print(" ALL TESTS PASSED!")
print("="*60)
print()
print("The application is ready to use!")
print()
print("Next steps:")
print(" 1. Configure your .env file")
print(" 2. Add client_secret.json for YouTube")
print(" 3. Start IPFS daemon for DTube")
print(" 4. Run: python app.py")
print()
return True
except Exception as e:
print()
print("="*60)
print(" TEST FAILED!")
print("="*60)
print(f"Error: {e}")
print()
import traceback
traceback.print_exc()
return False
if __name__ == '__main__':
import sys
success = main()
sys.exit(0 if success else 1)