ats-resume-optimizer / edge_case_test.py
Salim Shaikh
Add comprehensive fraud/gaming detection - 25/25 edge cases pass
3038a81
#!/usr/bin/env python3
"""
Edge Case Testing Suite - Finding Flaws in the ATS Optimizer
Tests scenarios designed to break or expose weaknesses in the system
"""
import json
import time
from datetime import datetime
from app import ATSCompatibilityAnalyzer, optimize_with_llm
analyzer = ATSCompatibilityAnalyzer()
# ============================================================================
# EDGE CASES DESIGNED TO FIND FLAWS
# ============================================================================
EDGE_CASES = {
# ==================== FORMAT EDGE CASES ====================
"Empty Resume": {
"category": "Format",
"description": "Completely empty resume",
"resume": "",
"job_description": "Software Engineer with Python experience",
"expected_issue": "Should handle gracefully without crashing"
},
"Minimal Resume - Just Name": {
"category": "Format",
"description": "Resume with only a name",
"resume": "John Doe",
"job_description": "Looking for a Data Analyst with SQL and Python experience, 3+ years",
"expected_issue": "Should score very low, not crash"
},
"All CAPS Resume": {
"category": "Format",
"description": "Entire resume in uppercase",
"resume": """
JOHN DOE
JOHN@EMAIL.COM | 555-123-4567
EXPERIENCE
SOFTWARE ENGINEER | TECHCORP | 2020 - PRESENT
- DEVELOPED PYTHON APPLICATIONS
- BUILT REST APIS
- MANAGED DATABASES
SKILLS: PYTHON, JAVA, SQL, AWS
""",
"job_description": "Software Engineer with Python and AWS experience",
"expected_issue": "Should still detect keywords despite caps"
},
"No Punctuation Resume": {
"category": "Format",
"description": "Resume without any punctuation or structure",
"resume": """
john doe johnemail com 5551234567 software engineer at techcorp
from 2020 to present developed python applications built rest apis
managed databases skills python java sql aws docker kubernetes
""",
"job_description": "Software Engineer with Python, Docker, Kubernetes",
"expected_issue": "Should still extract keywords without punctuation"
},
"Wall of Text Resume": {
"category": "Format",
"description": "Resume as one continuous paragraph",
"resume": """John Doe is a software engineer with 5 years of experience in Python and JavaScript development. He has worked at TechCorp since 2020 where he developed web applications using React and Node.js. He also has experience with AWS cloud services including EC2, S3, and Lambda. He managed databases using PostgreSQL and MongoDB. He led a team of 3 developers and improved system performance by 40%. He has a BS in Computer Science from State University. His skills include Python, JavaScript, React, Node.js, AWS, PostgreSQL, MongoDB, Docker, and Git.""",
"job_description": "Full Stack Developer with React, Node.js, and AWS experience",
"expected_issue": "Should parse keywords from unstructured text"
},
"Special Characters Resume": {
"category": "Format",
"description": "Resume with unusual special characters",
"resume": """
John Döe
jöhn@émäil.com | +1 (555) 123-4567
EXPERIENCE:
Sëñior Dévéloper @ TéchCörp™ | 2020–Present
• Dëveloped Python® applications
• Büilt REST APIs using Flask™
• Mänaged PostgreSQL® databases
SKILLS: Python™, Jävä™, SQL, AWS®, Döcker™
""",
"job_description": "Software Engineer with Python and AWS experience",
"expected_issue": "Should handle Unicode and special chars"
},
"Extremely Long Resume": {
"category": "Format",
"description": "10+ page resume with excessive detail",
"resume": """
John Doe | john@email.com | 555-123-4567 | linkedin.com/in/johndoe
SUMMARY
Senior Software Engineer with 15 years of experience in enterprise software development.
""" + "\n".join([f"""
Position {i} | Company {i} | {2020-i} - {2021-i}
• Developed application {i} using Python, Java, and JavaScript
• Built APIs serving {1000*i}+ requests per day
• Managed team of {i} developers
• Reduced costs by {i*5}% through optimization
• Implemented CI/CD pipelines using Jenkins
• Deployed to AWS using EC2, S3, Lambda
• Database management with PostgreSQL, MongoDB
• Achieved {90+i}% test coverage
""" for i in range(1, 20)]) + """
SKILLS
Python, Java, JavaScript, TypeScript, Go, Rust, C++, C#, Ruby, PHP,
React, Angular, Vue, Node.js, Django, Flask, Spring Boot,
AWS, Azure, GCP, Docker, Kubernetes, Terraform,
PostgreSQL, MySQL, MongoDB, Redis, Elasticsearch,
Jenkins, GitHub Actions, GitLab CI, CircleCI,
Agile, Scrum, Kanban, SAFe
EDUCATION
PhD Computer Science | MIT | 2005
MS Computer Science | Stanford | 2003
BS Computer Science | Berkeley | 2001
""",
"job_description": "Senior Software Engineer with Python and AWS experience",
"expected_issue": "Should handle very long resumes without timeout"
},
# ==================== CAREER TRANSITION EDGE CASES ====================
"Career Changer - Teacher to Tech": {
"category": "Career Transition",
"description": "Teacher transitioning to software engineering",
"resume": """
Sarah Johnson | sarah@email.com | 555-234-5678
EXPERIENCE
High School Math Teacher | Lincoln High | 2015 - 2023
• Taught algebra, geometry, and calculus to 150+ students
• Developed curriculum and lesson plans
• Used technology for interactive learning
• Mentored student math club
EDUCATION
MA Education | State University | 2015
BA Mathematics | State College | 2013
CERTIFICATIONS
State Teaching License
Google Certified Educator
RECENT TRAINING (Self-Study)
• Completed Python bootcamp (Codecademy)
• Built 3 personal projects on GitHub
• Learning React and JavaScript
""",
"job_description": """
Junior Software Engineer
Requirements:
- 2+ years software development experience
- Proficiency in Python, JavaScript, React
- Experience with REST APIs and databases
- CS degree or equivalent experience
""",
"expected_issue": "Career changers lack industry keywords - should still optimize"
},
"Career Changer - Military to Corporate": {
"category": "Career Transition",
"description": "Military veteran transitioning to project management",
"resume": """
James Miller | james@email.com | 555-345-6789
MILITARY EXPERIENCE
US Army Captain | 2010 - 2022
• Commanded platoon of 40 soldiers
• Planned and executed complex operations
• Managed $2M equipment budget
• Trained junior personnel
• Received Bronze Star for leadership
EDUCATION
BA Political Science | West Point | 2010
CLEARANCE
Top Secret/SCI (Active)
""",
"job_description": """
Project Manager
Requirements:
- 5+ years project management experience
- PMP certification preferred
- Experience with Agile/Scrum methodology
- Strong stakeholder management skills
- Budget management experience
""",
"expected_issue": "Military experience uses different terminology"
},
# ==================== ENTRY LEVEL EDGE CASES ====================
"Fresh Graduate - No Experience": {
"category": "Entry Level",
"description": "New graduate with only academic experience",
"resume": """
Alex Chen | alex@email.com
EDUCATION
BS Computer Science | State University | 2024
GPA: 3.8/4.0
COURSEWORK
Data Structures, Algorithms, Database Systems, Web Development
PROJECTS
• Built todo app using React (class project)
• Created simple Python script for data analysis
ACTIVITIES
Computer Science Club Member
""",
"job_description": """
Software Engineer
Requirements:
- 3+ years of professional experience
- Expert in Python and JavaScript
- Experience with cloud services (AWS/GCP)
- Track record of delivering production systems
""",
"expected_issue": "Fresh grads lack professional experience keywords"
},
"Internship Only": {
"category": "Entry Level",
"description": "Student with only internship experience",
"resume": """
Jamie Park | jamie@email.com | 555-456-7890
EDUCATION
BS Data Science | Tech University | Expected 2025
INTERNSHIP
Data Analyst Intern | StartupXYZ | Summer 2024
• Analyzed customer data using Excel
• Created charts and presentations
• Attended team meetings
SKILLS
Excel, PowerPoint, Basic Python
""",
"job_description": """
Senior Data Scientist
Requirements:
- 5+ years experience in data science
- Expert in Python, TensorFlow, PyTorch
- Experience deploying ML models to production
- PhD preferred
""",
"expected_issue": "Massive experience gap - should score appropriately low"
},
# ==================== OVERQUALIFIED EDGE CASES ====================
"CEO Applying for IC Role": {
"category": "Overqualified",
"description": "Executive applying for individual contributor role",
"resume": """
Robert Thompson | robert@email.com
EXECUTIVE EXPERIENCE
CEO | Global Tech Corp | 2015 - 2023
• Led company of 5,000 employees
• Managed $500M P&L
• Drove IPO valued at $2B
• Reported to Board of Directors
President | Tech Startup | 2010 - 2015
• Grew company from 50 to 500 employees
• Raised $100M in funding
EDUCATION
MBA | Harvard Business School | 2008
BS Engineering | MIT | 2004
""",
"job_description": """
Software Engineer
Requirements:
- 3+ years coding experience
- Proficiency in Python and JavaScript
- Experience with REST APIs
- Team player attitude
""",
"expected_issue": "Executive resume lacks technical keywords"
},
# ==================== NON-STANDARD EXPERIENCE EDGE CASES ====================
"Freelancer Resume": {
"category": "Non-Standard",
"description": "Freelancer with many short projects",
"resume": """
Taylor Williams | taylor@email.com | 555-567-8901
FREELANCE EXPERIENCE (2018 - Present)
Independent Web Developer
Client A (2 weeks): Built landing page
Client B (1 month): Created e-commerce site
Client C (3 weeks): Developed mobile app
Client D (2 months): Built CRM system
Client E (1 week): Fixed bugs
[+ 50 more clients]
PLATFORMS
Upwork: 5-star rating, Top Rated Plus
Fiverr: Level 2 Seller
SKILLS: HTML, CSS, JavaScript, WordPress, Shopify
""",
"job_description": """
Full-Time Software Engineer
Requirements:
- 3+ years at established company
- Experience with enterprise software
- Team collaboration experience
- Agile methodology
""",
"expected_issue": "Freelance experience structured differently"
},
"Volunteer Only Experience": {
"category": "Non-Standard",
"description": "Resume with only volunteer experience",
"resume": """
Casey Morgan | casey@email.com
VOLUNTEER EXPERIENCE
Website Developer | Local Nonprofit | 2022 - Present
• Built and maintain organization website
• Manage social media accounts
Coding Tutor | Community Center | 2021 - Present
• Teach Python basics to underprivileged youth
Event Organizer | Tech Meetup | 2020 - Present
• Organize monthly tech talks
EDUCATION
Self-taught programmer
Completed 20+ online courses
""",
"job_description": """
Software Engineer
Requirements:
- Professional software development experience
- Paid work history preferred
- Corporate environment experience
""",
"expected_issue": "No paid experience keywords"
},
# ==================== KEYWORD MISMATCH EDGE CASES ====================
"British English Resume": {
"category": "Keyword Mismatch",
"description": "Resume using British English spellings",
"resume": """
Oliver Smith | oliver@email.co.uk | +44 7700 900000
EXPERIENCE
Programme Manager | Barclays | 2020 - Present
• Organised cross-functional teams
• Optimised project delivery processes
• Analysed programme metrics and KPIs
• Specialised in Agile methodologies
• Prioritised stakeholder requirements
SKILLS
Programme Management, Organisation, Analysis, Optimisation
EDUCATION
MSc Computer Science | University of Cambridge | 2018
""",
"job_description": """
Program Manager (US Company)
Requirements:
- Program management experience
- Strong organizational skills
- Analytical capabilities
- Optimization expertise
""",
"expected_issue": "British vs American spelling differences"
},
"Acronym Heavy Resume": {
"category": "Keyword Mismatch",
"description": "Resume using only acronyms without expansion",
"resume": """
Alex Kim | alex@email.com
SR SWE @ FAANG | 2020 - Present
• Built ML/DL models for NLP
• Deployed to AWS (EC2, S3, EKS)
• Used K8s, TF, PyT, HF
• CI/CD with GHA, TF
• DB: PG, Mongo, Redis
SKILLS: PY, JS, TS, RX, NG, VUE, NJS, GO
EDU: MS CS @ MIT, BS EE @ Stanford
""",
"job_description": """
Senior Software Engineer
Requirements:
- Experience with Machine Learning and Deep Learning
- Natural Language Processing expertise
- Amazon Web Services cloud experience
- Kubernetes and Terraform
- Python, JavaScript, TypeScript
""",
"expected_issue": "Acronyms may not match expanded JD terms"
},
"Synonym Mismatch": {
"category": "Keyword Mismatch",
"description": "Resume uses synonyms instead of exact keywords",
"resume": """
Jordan Lee | jordan@email.com
EXPERIENCE
Tech Lead | StartupXYZ | 2020 - Present
• Supervised engineering squad of 8 coders
• Constructed web platforms using ReactJS
• Authored backend services in Python
• Steered Agile ceremonies and sprints
SKILLS
Supervision, Platform Construction, Backend Authoring, Sprint Steering
""",
"job_description": """
Engineering Manager
Requirements:
- Team leadership experience (manage developers)
- Built web applications using React
- Developed backend services
- Led Agile processes
""",
"expected_issue": "Unusual synonyms may not be recognized"
},
# ==================== INDUSTRY-SPECIFIC EDGE CASES ====================
"Healthcare - Foreign Credentials": {
"category": "Industry-Specific",
"description": "Foreign-trained physician",
"resume": """
Dr. Priya Sharma | priya@email.com
MEDICAL EXPERIENCE
Senior Registrar | Apollo Hospital, Mumbai | 2015 - 2022
• Treated 50+ patients daily in OPD
• Performed 200+ surgeries
• Supervised housemen and interns
EDUCATION
MBBS | AIIMS Delhi | 2010
MS Surgery | AIIMS Delhi | 2015
CERTIFICATIONS
Medical Council of India Registration
USMLE Step 1: 250
USMLE Step 2: 248
""",
"job_description": """
Physician - Internal Medicine (US Hospital)
Requirements:
- MD or DO from accredited US medical school
- Board certified in Internal Medicine
- Active state medical license
- 3+ years US clinical experience
- EMR experience (Epic/Cerner)
""",
"expected_issue": "Foreign credentials don't match US requirements"
},
"Legal - Different Jurisdiction": {
"category": "Industry-Specific",
"description": "UK solicitor applying for US attorney role",
"resume": """
William Clarke | william@email.co.uk
LEGAL EXPERIENCE
Solicitor | Clifford Chance LLP, London | 2015 - 2023
• Advised on cross-border M&A transactions
• Drafted share purchase agreements
• Conducted legal due diligence
QUALIFICATIONS
Solicitor of England and Wales (Admitted 2015)
LPC | BPP Law School | 2014
LLB | University of Oxford | 2013
""",
"job_description": """
Corporate Attorney (US Law Firm)
Requirements:
- JD from ABA-accredited law school
- Active bar membership (NY, CA, or other state)
- 5+ years US corporate law experience
- Experience with SEC filings
""",
"expected_issue": "Different legal systems and qualifications"
},
"Finance - Crypto/Web3 Role": {
"category": "Industry-Specific",
"description": "Traditional finance applying for Web3",
"resume": """
Michael Chen | michael@email.com
EXPERIENCE
Investment Analyst | Goldman Sachs | 2018 - 2023
• Analyzed equities and fixed income
• Built financial models in Excel
• Wrote research reports
EDUCATION
MBA | Wharton | 2018
BS Finance | NYU | 2014
CERTIFICATIONS
CFA Level III Candidate
""",
"job_description": """
DeFi Protocol Analyst
Requirements:
- Deep understanding of DeFi protocols (Uniswap, Aave, Compound)
- Experience with smart contract analysis
- Familiarity with Ethereum, Solidity
- Understanding of tokenomics and yield farming
- Web3 native preferred
""",
"expected_issue": "Traditional finance lacks crypto/DeFi keywords"
},
"Tech - Legacy Systems": {
"category": "Industry-Specific",
"description": "Mainframe developer applying for modern role",
"resume": """
Robert Johnson | robert@email.com
EXPERIENCE
Senior Mainframe Developer | Bank of America | 1995 - 2023
• Developed COBOL programs for batch processing
• Maintained JCL job scheduling
• Managed DB2 databases on z/OS
• Worked with CICS transaction processing
• 28 years of mainframe experience
SKILLS
COBOL, JCL, DB2, CICS, VSAM, z/OS, TSO/ISPF
EDUCATION
BS Computer Science | State University | 1993
""",
"job_description": """
Senior Software Engineer - Cloud Native
Requirements:
- Experience with microservices architecture
- Proficiency in Python, Go, or Rust
- Kubernetes and Docker expertise
- AWS/GCP cloud services
- CI/CD and DevOps practices
- Modern development frameworks
""",
"expected_issue": "Legacy tech stack completely different from modern"
},
# ==================== PROBLEMATIC CONTENT EDGE CASES ====================
"Resume with Employment Gaps": {
"category": "Problematic Content",
"description": "Resume with large unexplained gaps",
"resume": """
Pat Davis | pat@email.com
EXPERIENCE
Software Engineer | TechCorp | 2021 - 2022 (1 year)
• Developed web applications
[GAP: 2018 - 2021 - 3 years]
Junior Developer | StartupXYZ | 2016 - 2018 (2 years)
• Built features
[GAP: 2014 - 2016 - 2 years]
Intern | SmallCo | 2014 (6 months)
• Learned coding
SKILLS: Python, JavaScript
""",
"job_description": """
Software Engineer
- 5+ years continuous professional experience
- Stable work history
""",
"expected_issue": "Gaps may affect experience calculation"
},
"Resume with Job Hopping": {
"category": "Problematic Content",
"description": "Many short-term positions",
"resume": """
Sam Taylor | sam@email.com
EXPERIENCE
Software Engineer | Company A | Jan 2023 - Apr 2023 (4 months)
Software Engineer | Company B | Aug 2022 - Dec 2022 (5 months)
Developer | Company C | Mar 2022 - Jul 2022 (5 months)
Programmer | Company D | Oct 2021 - Feb 2022 (5 months)
Engineer | Company E | May 2021 - Sep 2021 (5 months)
Coder | Company F | Dec 2020 - Apr 2021 (5 months)
SKILLS: Python, JavaScript, Java, SQL
""",
"job_description": """
Senior Software Engineer
- 5+ years experience
- Looking for long-term commitment
- Stable work history preferred
""",
"expected_issue": "Many short stints may confuse date parsing"
},
# ==================== LANGUAGE EDGE CASES ====================
"Mixed Language Resume": {
"category": "Language",
"description": "Resume with multiple languages",
"resume": """
María García | maria@email.com
EXPERIENCIA PROFESIONAL
Desarrolladora de Software | TechCorp | 2020 - Present
• Developed Python applications (desarrollo de aplicaciones)
• Built REST APIs (construcción de APIs)
• Worked with databases (bases de datos)
HABILIDADES / SKILLS
Python, JavaScript, SQL, AWS, Docker
EDUCACIÓN / EDUCATION
Ingeniería en Sistemas | Universidad Nacional | 2018
BS Computer Science equivalent
""",
"job_description": """
Software Engineer
Requirements:
- Python and JavaScript experience
- REST API development
- Database experience
""",
"expected_issue": "Mixed language may confuse keyword extraction"
},
# ==================== NUMBERS/METRICS EDGE CASES ====================
"No Metrics Resume": {
"category": "Metrics",
"description": "Resume with zero quantification",
"resume": """
Chris Johnson | chris@email.com
EXPERIENCE
Software Engineer | TechCorp | 2020 - Present
• Developed applications
• Built APIs
• Worked with databases
• Collaborated with team
• Participated in meetings
Project Manager | OtherCorp | 2018 - 2020
• Managed projects
• Led team
• Delivered on time
SKILLS: Python, Project Management
""",
"job_description": "Software Engineer with measurable impact",
"expected_issue": "No quantification to score"
},
"Unrealistic Metrics": {
"category": "Metrics",
"description": "Resume with impossible/exaggerated numbers",
"resume": """
Alex Wonder | alex@email.com
EXPERIENCE
Software Engineer | TechCorp | 2022 - Present
• Improved performance by 99999%
• Saved company $500 billion
• Managed team of 10000 engineers
• Wrote 1 million lines of code per day
• Reduced bugs by 1000%
• Increased revenue by 50000%
SKILLS: Everything
""",
"job_description": "Software Engineer",
"expected_issue": "Unrealistic numbers still counted as quantification"
},
# ==================== CREATIVE/UNUSUAL RESUMES ====================
"Narrative Style Resume": {
"category": "Creative",
"description": "Resume written as a story",
"resume": """
The Journey of Jane Developer
It all started in 2015 when I wrote my first line of Python code. Little did I
know that this would lead to an incredible journey through the world of software
engineering. At TechCorp, where I've been since 2020, I discovered my passion for
building scalable systems. Every day, I wake up excited to tackle new challenges
with my amazing team. We use React for our frontend and Node.js for our backend,
all deployed on AWS. My proudest achievement was reducing our page load time by
50%, which increased user engagement significantly. I believe that great software
is built by people who truly care. That's why I'm looking for a new adventure
where I can make a real impact.
Contact me at jane@email.com to chat!
""",
"job_description": "Software Engineer with React and Node.js experience",
"expected_issue": "Non-standard narrative format"
},
"Emoji Resume": {
"category": "Creative",
"description": "Resume with emojis instead of bullets",
"resume": """
👤 John Developer
📧 john@email.com | 📱 555-123-4567
💼 EXPERIENCE
🏢 TechCorp | 💻 Software Engineer | 📅 2020 - Present
✨ Developed Python applications
🚀 Built scalable microservices
☁️ Deployed to AWS cloud
👥 Led team of 5 engineers
📈 Increased performance by 40%
🎓 EDUCATION
🎓 BS Computer Science | State University | 2019
🛠️ SKILLS
🐍 Python | ⚛️ React | 🟢 Node.js | 🐳 Docker | ☸️ Kubernetes
""",
"job_description": "Software Engineer with Python, React, Node.js",
"expected_issue": "Emojis may interfere with parsing"
},
}
def run_edge_case(name: str, case: dict) -> dict:
"""Run a single edge case test."""
resume = case["resume"]
job_desc = case["job_description"]
result = {
"name": name,
"category": case["category"],
"description": case["description"],
"expected_issue": case["expected_issue"],
"crashed": False,
"error_message": None,
"before_score": None,
"after_score": None,
"improvement": None,
"optimization_worked": None,
"issues_found": []
}
# Test 1: Does scoring work without crashing?
try:
before_result = analyzer.analyze(resume, job_desc)
result["before_score"] = before_result["total_score"]
result["before_breakdown"] = before_result["breakdown"]
except Exception as e:
result["crashed"] = True
result["error_message"] = f"Scoring crashed: {str(e)}"
result["issues_found"].append(f"CRASH on scoring: {str(e)[:100]}")
return result
# Test 2: Does optimization work without crashing?
try:
optimized, changes = optimize_with_llm(resume, job_desc)
result["optimization_worked"] = True
result["num_changes"] = len(changes)
# Check if optimization actually changed anything
if optimized.strip() == resume.strip():
result["issues_found"].append("Optimization made no changes")
elif len(optimized) < len(resume) * 0.5:
result["issues_found"].append(f"Optimization shortened resume significantly ({len(resume)} -> {len(optimized)})")
except Exception as e:
result["optimization_worked"] = False
result["error_message"] = f"Optimization failed: {str(e)}"
result["issues_found"].append(f"Optimization error: {str(e)[:100]}")
optimized = resume # Fall back to original
# Test 3: Get after score
try:
after_result = analyzer.analyze(optimized, job_desc)
result["after_score"] = after_result["total_score"]
result["after_breakdown"] = after_result["breakdown"]
result["improvement"] = result["after_score"] - result["before_score"]
# Check for issues
if result["after_score"] < result["before_score"]:
result["issues_found"].append(f"Optimization DECREASED score: {result['before_score']} -> {result['after_score']}")
if result["after_score"] < 60:
result["issues_found"].append(f"Very low final score: {result['after_score']}%")
except Exception as e:
result["crashed"] = True
result["error_message"] = f"Post-optimization scoring crashed: {str(e)}"
result["issues_found"].append(f"CRASH on post-scoring: {str(e)[:100]}")
return result
def run_all_edge_cases():
"""Run all edge case tests and report findings."""
print("=" * 70)
print("EDGE CASE TESTING SUITE - FINDING FLAWS")
print("=" * 70)
print(f"\nTesting {len(EDGE_CASES)} edge cases...\n")
all_results = []
issues_by_category = {}
for i, (name, case) in enumerate(EDGE_CASES.items(), 1):
print(f"[{i}/{len(EDGE_CASES)}] {name}...", end=" ", flush=True)
result = run_edge_case(name, case)
all_results.append(result)
# Track issues by category
category = case["category"]
if category not in issues_by_category:
issues_by_category[category] = []
# Determine status
if result["crashed"]:
status = "💥 CRASHED"
issues_by_category[category].append(result)
elif result["issues_found"]:
status = "⚠️ ISSUES"
issues_by_category[category].append(result)
elif result["after_score"] and result["after_score"] >= 80:
status = "✅ PASSED"
elif result["after_score"] and result["after_score"] >= 60:
status = "⚠️ LOW"
issues_by_category[category].append(result)
else:
status = "🔴 FAILED"
issues_by_category[category].append(result)
if result["before_score"] is not None and result["after_score"] is not None:
print(f"{result['before_score']}% → {result['after_score']}% {status}")
else:
print(f"{status}")
# Add delay to avoid rate limiting
time.sleep(1)
# Summary Report
print("\n" + "=" * 70)
print("EDGE CASE RESULTS SUMMARY")
print("=" * 70)
# Crashes
crashes = [r for r in all_results if r["crashed"]]
print(f"\n💥 CRASHES: {len(crashes)}/{len(all_results)}")
for r in crashes:
print(f" - {r['name']}: {r['error_message'][:60]}")
# Optimization failures
opt_failures = [r for r in all_results if r["optimization_worked"] == False]
print(f"\n❌ OPTIMIZATION FAILURES: {len(opt_failures)}/{len(all_results)}")
for r in opt_failures:
print(f" - {r['name']}: {r.get('error_message', 'Unknown')[:60]}")
# Score decreased after optimization
score_decreased = [r for r in all_results if r["improvement"] is not None and r["improvement"] < 0]
print(f"\n📉 SCORE DECREASED AFTER OPTIMIZATION: {len(score_decreased)}/{len(all_results)}")
for r in score_decreased:
print(f" - {r['name']}: {r['before_score']}% → {r['after_score']}% ({r['improvement']})")
# Very low final scores
low_scores = [r for r in all_results if r["after_score"] is not None and r["after_score"] < 70]
print(f"\n🔴 LOW FINAL SCORES (<70%): {len(low_scores)}/{len(all_results)}")
for r in low_scores:
print(f" - {r['name']}: {r['after_score']}%")
# Issues by category
print("\n" + "=" * 70)
print("ISSUES BY CATEGORY")
print("=" * 70)
for category, issues in sorted(issues_by_category.items()):
if issues:
print(f"\n📁 {category}: {len(issues)} issues")
for r in issues:
print(f" • {r['name']}")
for issue in r.get("issues_found", []):
print(f" → {issue}")
# Overall stats
print("\n" + "=" * 70)
print("OVERALL STATISTICS")
print("=" * 70)
successful = [r for r in all_results if not r["crashed"] and r["optimization_worked"]]
if successful:
avg_before = sum(r["before_score"] for r in successful) / len(successful)
avg_after = sum(r["after_score"] for r in successful) / len(successful)
avg_improvement = sum(r["improvement"] for r in successful) / len(successful)
print(f"\nSuccessful tests: {len(successful)}/{len(all_results)}")
print(f"Average before: {avg_before:.1f}%")
print(f"Average after: {avg_after:.1f}%")
print(f"Average improvement: {avg_improvement:+.1f}%")
# Recommendations
print("\n" + "=" * 70)
print("RECOMMENDATIONS FOR IMPROVEMENT")
print("=" * 70)
recommendations = []
if crashes:
recommendations.append("• Add better error handling for edge case inputs (empty, malformed)")
if score_decreased:
recommendations.append("• Review LLM prompt to prevent content removal during optimization")
if any("British" in r["name"] for r in low_scores):
recommendations.append("• Add British/American English synonym mapping")
if any("Acronym" in r["name"] for r in low_scores):
recommendations.append("• Expand acronym recognition and expansion")
if any("Career" in r["category"] for r in issues_by_category.get("Career Transition", [])):
recommendations.append("• Add transferable skills detection for career changers")
if any("Legacy" in r["name"] for r in low_scores):
recommendations.append("• Add legacy technology to modern equivalent mapping")
if any("Foreign" in r["name"] or "jurisdiction" in r["name"].lower() for r in low_scores):
recommendations.append("• Add international credential recognition")
for rec in recommendations or ["• All edge cases handled well!"]:
print(rec)
# Save results
results_file = f"edge_case_results_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"
with open(results_file, 'w') as f:
json.dump({
"timestamp": datetime.now().isoformat(),
"total_tests": len(all_results),
"crashes": len(crashes),
"optimization_failures": len(opt_failures),
"score_decreased": len(score_decreased),
"low_scores": len(low_scores),
"results": all_results
}, f, indent=2, default=str)
print(f"\n💾 Results saved to: {results_file}")
return all_results
if __name__ == "__main__":
run_all_edge_cases()