File size: 2,555 Bytes
7b7bdab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# OpenInterpreter Test Runner Script

echo "πŸ§ͺ OpenInterpreter Test Suite"
echo "=============================="

# Set up environment
export PYTHONPATH="/workspaces/fastapi_django_main_live:$PYTHONPATH"

# Check if pytest is installed
if ! command -v pytest &> /dev/null; then
    echo "Installing pytest..."
    pip install pytest pytest-cov pytest-asyncio
fi

echo ""
echo "πŸ”§ Running OpenInterpreter Tests..."
echo "===================================="

# Run the test file directly first
echo "1. Running basic functionality tests..."
cd /workspaces/fastapi_django_main_live
python -m tests.test_openinterpreter

echo ""
echo "πŸš€ Starting Test API Server..."
echo "=============================="

# Start the test API server in background
echo "Starting test API on port 7861..."
python test_app.py &
TEST_API_PID=$!

# Wait for the server to start
sleep 3

echo ""
echo "πŸ§ͺ Testing API Endpoints..."
echo "============================"

# Test the API endpoints using curl
echo "Testing health endpoint..."
curl -s http://localhost:7861/health | python -m json.tool

echo ""
echo "Testing code validation..."
curl -s -X POST http://localhost:7861/test/validate-code \
  -H "Content-Type: application/json" \
  -d '{"code": "print(\"Hello, World!\")"}' | python -m json.tool

echo ""
echo "Testing database functionality..."
curl -s http://localhost:7861/test/database | python -m json.tool

echo ""
echo "Running comprehensive test suite..."
curl -s http://localhost:7861/test/suite | python -m json.tool

echo ""
echo "Testing basic chat (this may take a moment)..."
curl -s -X POST http://localhost:7861/test/chat \
  -H "Content-Type: application/json" \
  -d '{"message": "What is 2+2?", "password": "12345"}' | python -m json.tool

# Clean up - stop the test API server
echo ""
echo "🧹 Cleaning up..."
kill $TEST_API_PID 2>/dev/null

echo ""
echo "πŸ“Š Test Summary"
echo "==============="
echo "βœ“ Basic functionality tests completed"
echo "βœ“ API endpoint tests completed"
echo "βœ“ Code validation tests completed"
echo "βœ“ Database operation tests completed"
echo "βœ“ Chat functionality tests completed"

echo ""
echo "🎯 To run the test API manually:"
echo "  python test_app.py"
echo "  # Then visit http://localhost:7861/docs for API documentation"

echo ""
echo "πŸ” To run specific tests:"
echo "  pytest tests/test_openinterpreter.py::TestOpenInterpreter::test_validate_code_valid"
echo "  pytest tests/test_openinterpreter.py -k \"code_validation\""

echo ""
echo "πŸ“ Test completed successfully!"