69 lines
No EOL
2 KiB
Python
Executable file
69 lines
No EOL
2 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""
|
|
Test script to fetch a few LinkedIn profiles using Exa API.
|
|
"""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
def main():
|
|
"""Test fetching a few profiles."""
|
|
# Check if ZAI_API_TOKEN is set
|
|
if not os.environ.get('ZAI_API_TOKEN'):
|
|
print("Error: ZAI_API_TOKEN environment variable not set")
|
|
print("Please set it in your environment or .env file")
|
|
print("\nTo set it temporarily:")
|
|
print(" export ZAI_API_TOKEN=your_token_here")
|
|
print(" python test_fetch_profiles.py")
|
|
sys.exit(1)
|
|
|
|
# Create a small test file with just a few URLs
|
|
test_file = Path("/tmp/test_staff.json")
|
|
test_data = {
|
|
"staff": [
|
|
{
|
|
"name": "Test Person 1",
|
|
"linkedin_url": "https://www.linkedin.com/in/christel-schollaardt-0a605b7"
|
|
},
|
|
{
|
|
"name": "Test Person 2",
|
|
"linkedin_url": "https://www.linkedin.com/in/lodewijkwisse"
|
|
},
|
|
{
|
|
"name": "Test Person 3",
|
|
"linkedin_url": "https://www.linkedin.com/in/rogier-van-der-sande-57436a1"
|
|
}
|
|
]
|
|
}
|
|
|
|
import json
|
|
with open(test_file, 'w') as f:
|
|
json.dump(test_data, f, indent=2)
|
|
|
|
print("Created test file with 3 LinkedIn URLs")
|
|
print(f"Test file: {test_file}")
|
|
|
|
# Run the fetcher on this test file
|
|
fetcher_script = "/Users/kempersc/apps/glam/scripts/fetch_linkedin_profiles_exa_final.py"
|
|
cmd = ["python", fetcher_script, str(test_file)]
|
|
|
|
print(f"\nRunning: {' '.join(cmd)}")
|
|
print()
|
|
|
|
# Run the command
|
|
result = subprocess.run(cmd, capture_output=False, text=True)
|
|
|
|
# Clean up test file
|
|
test_file.unlink()
|
|
|
|
if result.returncode == 0:
|
|
print("\n✓ Test completed successfully!")
|
|
else:
|
|
print(f"\n✗ Test failed with exit code {result.returncode}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |