File size: 2,558 Bytes
30e5fc4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6e1b170
 
 
 
 
 
 
 
 
 
 
 
30e5fc4
6e1b170
 
 
 
30e5fc4
6e1b170
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
"""
Verification script to test app functionality locally.
"""
import os
import sys

# Add current directory to path
sys.path.append(os.getcwd())

try:
    from app import analyze_input
    from rag_agent import RAGAgent
    print("βœ… Successfully imported app modules")
except ImportError as e:
    print(f"❌ Import failed: {e}")
    sys.exit(1)

def test_rag():
    print("\nTesting RAG Agent...")
    agent = RAGAgent()
    
    # Create a dummy file to index
    os.makedirs("test_data", exist_ok=True)
    with open("test_data/test.txt", "w") as f:
        f.write("This is a test file for the RAG agent.")
        
    if not os.getenv("OPENAI_API_KEY"):
        print("⚠️ OPENAI_API_KEY not found. Skipping actual indexing/querying.")
        return

    status = agent.index_codebase("test_data")
    print(f"Index Status: {status}")
    
    if "βœ…" in status:
        response = agent.query_codebase("What is this file about?")
        print(f"Query Response: {response}")
    else:
        print("❌ Indexing failed")

def test_analysis():
    print("\nTesting Analysis...")
    # Test with manual input to avoid needing a real repo/zip for now
    result, project, summary, diagram, fixes = analyze_input(None, "", True)
    print(f"Manual Analysis Result: {len(result)} chars")
    
    # Test with user's GitHub repo
    repo_url = "https://github.com/himanshu748/Technical_Training_Project"
    print(f"Testing with Repo: {repo_url}")
    result, project, summary, diagram, fixes = analyze_input(None, repo_url, False)
    print(f"GitHub Analysis Result Project Name: {project}")
    if "Error" in result:
        print(f"❌ Analysis Failed: {result}")
    else:
        print(f"βœ… Analysis Successful. Summary length: {len(summary)}")
        print(f"βœ… Diagram Generated: {len(diagram)} chars")
        print(f"βœ… Fixes Identified: {len(fixes)}")

    # Test Updates Check
    print("\nTesting Updates Check...")
    # Mocking analysis for updates
    mock_analysis = {"dependencies": ["flask", "requests", "gunicorn"]}
    updates = analyzer.check_updates(mock_analysis)
    print(f"βœ… Updates Found: {len(updates)}")
    
    # Test Deployment Trigger
    print("\nTesting Deployment Trigger...")
    deploy_msg = asyncio.run(deploy_action("Vercel", repo_url))
    print(f"βœ… Deployment Message: {deploy_msg[:50]}...")

if __name__ == "__main__":
    # Mocking gradio components for local test
    async def deploy_action(platform, repo):
        return f"Deployed to {platform}"
        
    test_analysis()
    test_rag()