-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_excel_api.py
More file actions
80 lines (63 loc) · 2.78 KB
/
test_excel_api.py
File metadata and controls
80 lines (63 loc) · 2.78 KB
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
#!/usr/bin/env python3
"""
Test script to verify Excel export functionality via API
"""
import requests
import json
import time
import os
import pandas as pd
from datetime import datetime
# API endpoint
BASE_URL = "http://localhost:8000"
def test_excel_export():
"""Test Excel export with company name and LinkedIn URL fixes"""
print("🧪 Testing Excel Export API...")
# Test request
payload = {
"query": "Frontend Developer",
"location": "New York",
"limit": 3,
"job_description": "Looking for frontend developers with React experience",
"export_excel": True
}
print(f"📤 Sending request: {json.dumps(payload, indent=2)}")
try:
response = requests.post(f"{BASE_URL}/source-candidates", json=payload)
if response.status_code == 200:
result = response.json()
print(f"✅ Success! Job ID: {result['job_id']}")
print(f"📊 Found {result['candidates_found']} candidates")
# Find the most recent Excel file
excel_dir = "outputs/excel_exports"
excel_files = [f for f in os.listdir(excel_dir) if f.endswith('.xlsx') and not f.startswith('~$')]
latest_file = max(excel_files, key=lambda f: os.path.getmtime(os.path.join(excel_dir, f)))
print(f"📁 Latest Excel file: {latest_file}")
# Read and verify the Excel file
excel_path = os.path.join(excel_dir, latest_file)
df = pd.read_excel(excel_path, sheet_name='Candidates')
print("\n🔍 Verifying Excel Content:")
print("=" * 60)
print(df[['Name', 'Company', 'LinkedIn_URL']].to_string(index=False))
print("=" * 60)
# Check if companies are clean (no technical expertise)
for index, row in df.iterrows():
company = row['Company']
if '•' in company or '|' in company:
print(f"⚠️ Warning: Company '{company}' still contains technical details")
else:
print(f"✅ Clean company name: '{company}'")
# Check LinkedIn URLs
for index, row in df.iterrows():
linkedin_url = row['LinkedIn_URL']
if linkedin_url and 'linkedin.com' in linkedin_url:
print(f"✅ LinkedIn URL present: {row['Name']}")
else:
print(f"❌ Missing LinkedIn URL: {row['Name']}")
else:
print(f"❌ Error: {response.status_code}")
print(response.text)
except Exception as e:
print(f"❌ Error: {e}")
if __name__ == "__main__":
test_excel_export()