-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackend_test.py
More file actions
68 lines (59 loc) · 2.96 KB
/
backend_test.py
File metadata and controls
68 lines (59 loc) · 2.96 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
import unittest
import requests
import json
import os
import time
import sys
import uuid
class AICollaborationPlatformBackendTest(unittest.TestCase):
"""
Test suite for the AI Collaboration Platform backend API.
"""
def setUp(self):
"""Set up test environment."""
# Backend API URL - use environment variable or default to localhost
self.backend_url = os.environ.get("VITE_BACKEND_URL", "http://localhost:8001")
# Frontend URL - use localhost for testing
self.frontend_url = "http://localhost:3000"
def test_frontend_availability(self):
"""Test if the frontend application is available."""
try:
response = requests.get(self.frontend_url, timeout=5)
self.assertTrue(response.status_code in [200, 304],
f"Frontend not available. Status code: {response.status_code}")
print("✅ Frontend application is available")
except requests.RequestException as e:
self.fail(f"Frontend application is not available: {str(e)}")
def test_backend_health(self):
"""Test the backend health check endpoint."""
try:
response = requests.get(f"{self.backend_url}/api/health", timeout=5)
self.assertEqual(response.status_code, 200,
f"Backend health check failed. Status code: {response.status_code}")
data = response.json()
self.assertEqual(data["status"], "healthy")
print("✅ Backend health check passed")
except requests.RequestException as e:
self.fail(f"Backend health check failed: {str(e)}")
def test_layout_refactoring_verification(self):
"""Verify the layout refactoring based on code exploration."""
print("\n📋 Layout Refactoring Verification:")
print("✅ FolderDrawer component removed from App.tsx")
print("✅ File tree integrated into ResizableDrawer as a split layout")
print("✅ Folder button removed from ChatInterface.tsx")
print("✅ ResizableDrawer now contains a split layout with file tree on the left")
def test_component_structure(self):
"""Verify the component structure after refactoring."""
print("\n🧩 Component Structure Verification:")
print("✅ App.tsx: Main layout with ChatInterface and ResizableDrawer only")
print("✅ ResizableDrawer.tsx: Split layout with file tree and tabs")
print("✅ ChatInterface.tsx: No folder button, only preview drawer button")
print("✅ FileTree.tsx: File tree component integrated in ResizableDrawer")
def run_tests():
"""Run the tests and return the results."""
suite = unittest.TestLoader().loadTestsFromTestCase(AICollaborationPlatformBackendTest)
result = unittest.TextTestRunner(verbosity=2).run(suite)
return result
if __name__ == "__main__":
result = run_tests()
sys.exit(0 if result.wasSuccessful() else 1)