Stack_Overflow_MCP_Server / test_live_demo.py
MarkNawar's picture
Upload folder using huggingface_hub
a6bfba7 verified
#!/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()