Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Quick validation test for the fixed scoring system | |
| """ | |
| from app import ATSCompatibilityAnalyzer, optimize_with_llm | |
| analyzer = ATSCompatibilityAnalyzer() | |
| print("=" * 70) | |
| print("VALIDATION: Fixed Scoring System") | |
| print("=" * 70) | |
| # Test cases with expected behavior | |
| tests = [ | |
| { | |
| "name": "Empty Resume", | |
| "resume": "", | |
| "jd": "Software Engineer with Python", | |
| "expected_score_max": 15, | |
| "expected_behavior": "Low score, optimization blocked" | |
| }, | |
| { | |
| "name": "Just Name", | |
| "resume": "John Doe", | |
| "jd": "Data Scientist with ML experience", | |
| "expected_score_max": 15, | |
| "expected_behavior": "Low score, optimization blocked" | |
| }, | |
| { | |
| "name": "Chef for ML Role (Complete Mismatch)", | |
| "resume": """ | |
| Chef John Smith | |
| Executive Chef | Le Restaurant | 2015-2023 | |
| β’ Created award-winning French cuisine menus | |
| β’ Managed kitchen staff of 20 | |
| β’ Sourced local organic ingredients | |
| Skills: French cuisine, pastry, wine pairing | |
| Education: Culinary Institute of America | |
| """, | |
| "jd": "Machine Learning Engineer with PhD, PyTorch, TensorFlow experience", | |
| "expected_score_max": 35, | |
| "expected_behavior": "Low score due to zero keyword overlap" | |
| }, | |
| { | |
| "name": "Matching Resume", | |
| "resume": """ | |
| Sarah Johnson | sarah@email.com | 555-123-4567 | |
| EXPERIENCE | |
| Senior Software Engineer | TechCorp | 2020 - Present | |
| β’ Developed Python applications using Django and Flask | |
| β’ Built REST APIs serving 1M+ requests daily | |
| β’ Deployed to AWS using EC2, S3, Lambda | |
| β’ Collaborated with cross-functional teams | |
| β’ Led team of 5 engineers | |
| Software Developer | StartupXYZ | 2017 - 2020 | |
| β’ Developed web applications using JavaScript and React | |
| β’ Implemented CI/CD pipelines using Jenkins | |
| β’ Managed PostgreSQL databases | |
| SKILLS | |
| Python, JavaScript, React, Django, Flask, AWS, Docker, PostgreSQL, Git | |
| EDUCATION | |
| BS Computer Science | State University | 2017 | |
| """, | |
| "jd": """ | |
| Software Engineer | |
| Requirements: | |
| - 3+ years Python experience | |
| - REST API development | |
| - AWS cloud services | |
| - Team collaboration | |
| """, | |
| "expected_score_min": 70, | |
| "expected_behavior": "High score due to keyword match" | |
| }, | |
| ] | |
| print("\nπ TEST RESULTS:\n") | |
| all_passed = True | |
| for test in tests: | |
| score = analyzer.analyze(test["resume"], test["jd"])["total_score"] | |
| # Check conditions | |
| passed = True | |
| if "expected_score_max" in test and score > test["expected_score_max"]: | |
| passed = False | |
| if "expected_score_min" in test and score < test["expected_score_min"]: | |
| passed = False | |
| status = "β PASS" if passed else "β FAIL" | |
| all_passed = all_passed and passed | |
| print(f"{status} | {test['name']}") | |
| print(f" Score: {score}%") | |
| if "expected_score_max" in test: | |
| print(f" Expected: β€{test['expected_score_max']}%") | |
| if "expected_score_min" in test: | |
| print(f" Expected: β₯{test['expected_score_min']}%") | |
| print(f" Behavior: {test['expected_behavior']}") | |
| print() | |
| # Test optimization blocking | |
| print("-" * 70) | |
| print("π TESTING OPTIMIZATION BLOCKING:") | |
| print("-" * 70) | |
| # Empty resume | |
| optimized, suggestions = optimize_with_llm("", "Software Engineer") | |
| if "ERROR" in suggestions[0]: | |
| print("β Empty resume: Optimization correctly blocked") | |
| print(f" Message: {suggestions[0][:60]}...") | |
| else: | |
| print("β Empty resume: Should have been blocked!") | |
| all_passed = False | |
| # Short resume | |
| optimized, suggestions = optimize_with_llm("John Doe, Developer", "Software Engineer") | |
| if "ERROR" in suggestions[0]: | |
| print("β Short resume: Optimization correctly blocked") | |
| print(f" Message: {suggestions[0][:60]}...") | |
| else: | |
| print("β Short resume: Should have been blocked!") | |
| all_passed = False | |
| # Valid resume (should NOT be blocked) | |
| valid_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, JavaScript, SQL | |
| EDUCATION | |
| BS Computer Science | 2019 | |
| """ | |
| optimized, suggestions = optimize_with_llm(valid_resume, "Software Engineer with Python and AWS experience") | |
| if "ERROR" not in suggestions[0]: | |
| print("β Valid resume: Optimization allowed") | |
| else: | |
| print("β Valid resume: Should NOT have been blocked!") | |
| all_passed = False | |
| print("\n" + "=" * 70) | |
| if all_passed: | |
| print("π ALL TESTS PASSED - Scoring system is working correctly!") | |
| else: | |
| print("β οΈ SOME TESTS FAILED - Review the results above") | |
| print("=" * 70) | |