#!/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()