File size: 2,520 Bytes
a6bfba7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Live Demo Test - Stack Overflow MCP Server
This script makes actual API calls to demonstrate the working functionality.
"""

import sys
import os
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from gradio_app import search_by_query_sync, search_by_error_sync, get_question_sync

def test_live_functionality():
    """Test the actual functionality of our Stack Overflow MCP server."""
    
    print("πŸ§ͺ LIVE FUNCTIONALITY TEST")
    print("=" * 60)
    
    # Test 1: General Search
    print("\n1️⃣ Testing General Search...")
    print("Query: 'python list comprehension'")
    print("Tags: 'python'")
    print("-" * 40)
    
    try:
        result = search_by_query_sync(
            query="python list comprehension", 
            tags="python",
            min_score=10,
            has_accepted_answer=True,
            limit=2,
            response_format="markdown"
        )
        print("βœ… SUCCESS:")
        print(result[:500] + "..." if len(result) > 500 else result)
    except Exception as e:
        print(f"❌ ERROR: {e}")
    
    print("\n" + "=" * 60)
    
    # Test 2: Error Search
    print("\n2️⃣ Testing Error Search...")
    print("Error: 'TypeError: NoneType'")
    print("Language: 'python'")
    print("-" * 40)
    
    try:
        result = search_by_error_sync(
            error_message="TypeError: NoneType object has no attribute",
            language="python",
            technologies="",
            min_score=5,
            has_accepted_answer=True,
            limit=2,
            response_format="markdown"
        )
        print("βœ… SUCCESS:")
        print(result[:500] + "..." if len(result) > 500 else result)
    except Exception as e:
        print(f"❌ ERROR: {e}")
    
    print("\n" + "=" * 60)
    
    # Test 3: Get Question
    print("\n3️⃣ Testing Get Question...")
    print("Question ID: 11227809 (Famous sorting question)")
    print("-" * 40)
    
    try:
        result = get_question_sync(
            question_id="11227809",
            include_comments=False,
            response_format="markdown"
        )
        print("βœ… SUCCESS:")
        print(result[:500] + "..." if len(result) > 500 else result)
    except Exception as e:
        print(f"❌ ERROR: {e}")
    
    print("\n" + "=" * 60)
    print("🎯 Live functionality test completed!")
    print("πŸš€ All functions are working and connected to Stack Overflow API")

if __name__ == "__main__":
    test_live_functionality()