Team Ai
Apppublic

kernelmind/Resume-Screener-API

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
test_api.py112 linesDownload Raw Back to root
1"""Test the /screen endpoint with a PDF resume."""2import requests3from io import BytesIO4from reportlab.lib.pagesizes import letter5from reportlab.pdfgen import canvas6 7def create_test_pdf():8    """Create a simple PDF resume for testing."""9    buffer = BytesIO()10    c = canvas.Canvas(buffer, pagesize=letter)11    12    # Add resume content13    c.setFont("Helvetica-Bold", 16)14    c.drawString(100, 750, "SARAH CHEN")15    16    c.setFont("Helvetica", 12)17    c.drawString(100, 730, "Senior Software Engineer")18    c.drawString(100, 715, "Email: sarah.chen@email.com | San Francisco, CA")19    20    c.setFont("Helvetica-Bold", 12)21    c.drawString(100, 685, "PROFESSIONAL SUMMARY")22    c.setFont("Helvetica", 10)23    c.drawString(100, 670, "Experienced software engineer with 6+ years of experience in Python,")24    c.drawString(100, 658, "JavaScript, and cloud technologies. Strong background in building")25    c.drawString(100, 646, "scalable web applications and microservices.")26    27    c.setFont("Helvetica-Bold", 12)28    c.drawString(100, 616, "TECHNICAL SKILLS")29    c.setFont("Helvetica", 10)30    c.drawString(100, 601, "Languages: Python, JavaScript, TypeScript, Go")31    c.drawString(100, 589, "Frameworks: FastAPI, Django, React, Node.js")32    c.drawString(100, 577, "Cloud: AWS (EC2, S3, Lambda), Docker, Kubernetes")33    c.drawString(100, 565, "Databases: PostgreSQL, MongoDB, Redis")34    35    c.setFont("Helvetica-Bold", 12)36    c.drawString(100, 535, "WORK EXPERIENCE")37    c.setFont("Helvetica-Bold", 10)38    c.drawString(100, 520, "Senior Software Engineer | Tech Corp Inc. | 2020 - Present")39    c.setFont("Helvetica", 10)40    c.drawString(110, 505, "- Led development of microservices architecture serving 1M+ users")41    c.drawString(110, 493, "- Implemented CI/CD pipelines reducing deployment time by 60%")42    43    c.setFont("Helvetica-Bold", 10)44    c.drawString(100, 468, "Software Engineer | StartupXYZ | 2018 - 2020")45    c.setFont("Helvetica", 10)46    c.drawString(110, 453, "- Built RESTful APIs using Python and FastAPI")47    c.drawString(110, 441, "- Developed React frontend for customer dashboard")48    49    c.setFont("Helvetica-Bold", 12)50    c.drawString(100, 411, "EDUCATION")51    c.setFont("Helvetica", 10)52    c.drawString(100, 396, "Bachelor of Science in Computer Science | UC Berkeley | 2018")53    54    c.save()55    buffer.seek(0)56    return buffer.getvalue()57 58API_URL = "http://localhost:8001/api/v1/screen"59 60job_description = """61Job Title: Senior Backend Engineer62 63Requirements:64- 5+ years of experience with Python65- Experience with FastAPI or Django66- Strong knowledge of AWS and Docker67- Experience with PostgreSQL68- Good communication skills69"""70 71print("Creating test PDF resume...")72pdf_content = create_test_pdf()73print(f"PDF created ({len(pdf_content)} bytes)")74 75print("\nTesting /screen endpoint...")76try:77    files = {"file": ("resume.pdf", pdf_content, "application/pdf")}78    data = {"job_description": job_description}79    80    response = requests.post(API_URL, files=files, data=data, timeout=120)81    print(f"Status Code: {response.status_code}")82    83    if response.status_code == 200:84        result = response.json()85        print("\n" + "="*50)86        print("✅ SUCCESS!")87        print("="*50)88        r = result.get('result', {})89        print(f"Similarity Score: {r.get('similarity_score', 'N/A'):.2%}")90        print(f"Fairness Score: {r.get('fairness_score', 'N/A')}")91        92        extracted = r.get('extracted_data', {})93        print(f"\nCandidate Name: {extracted.get('candidate_name', 'N/A')}")94        print(f"Experience: {extracted.get('total_experience_years', 'N/A')} years")95        print(f"Is Student: {extracted.get('is_student', 'N/A')}")96        97        skills = extracted.get('technical_skills', [])98        print(f"\nTechnical Skills Found ({len(skills)}):")99        for s in skills[:15]:100            print(f"  - {s}")101        102        print(f"\nMatch Analysis: {r.get('match_analysis', 'N/A')[:200]}...")103        print("="*50)104    else:105        print(f"\n❌ FAILED!")106        print(f"Response: {response.text[:2000]}")107        108except Exception as e:109    import traceback110    print(f"\n❌ ERROR: {e}")111    traceback.print_exc()112