|
| 1 | +from src.agents.resume_generation_agent import ResumeGenerationAgent |
| 2 | +from src.schemas import CandidateProfile, FitAnalysis, ResumeGenerationAgentOutput, TailoredResumeDraft, TailoringAgentOutput |
| 3 | + |
| 4 | + |
| 5 | +class FakePronounResumeOpenAIService: |
| 6 | + model = "fake-model" |
| 7 | + |
| 8 | + @staticmethod |
| 9 | + def is_available(): |
| 10 | + return True |
| 11 | + |
| 12 | + @staticmethod |
| 13 | + def run_json_prompt(system_prompt, user_prompt, expected_keys=None, **kwargs): |
| 14 | + return { |
| 15 | + "professional_summary": "I am a project-based machine learning candidate with strong predictive modeling experience.", |
| 16 | + "highlighted_skills": ["Python", "SQL", "XGBoost"], |
| 17 | + "experience_bullets": [ |
| 18 | + "I built predictive models for fraud detection.", |
| 19 | + "Leander Antony developed validation workflows for ML projects.", |
| 20 | + ], |
| 21 | + "section_order": ["Professional Summary", "Core Skills", "Professional Experience", "Education"], |
| 22 | + "template_hint": "classic_ats", |
| 23 | + } |
| 24 | + |
| 25 | + |
| 26 | +def test_resume_generation_agent_falls_back_when_ai_uses_self_referential_resume_voice(): |
| 27 | + agent = ResumeGenerationAgent(openai_service=FakePronounResumeOpenAIService()) |
| 28 | + candidate_profile = CandidateProfile(full_name="Leander Antony") |
| 29 | + fit_analysis = FitAnalysis( |
| 30 | + target_role="Data Scientist", |
| 31 | + overall_score=84, |
| 32 | + readiness_label="Strong", |
| 33 | + matched_hard_skills=["Python", "SQL", "XGBoost"], |
| 34 | + ) |
| 35 | + tailored_draft = TailoredResumeDraft( |
| 36 | + target_role="Data Scientist", |
| 37 | + professional_summary="Candidate profile aligned to Data Scientist with grounded evidence around Python, SQL, XGBoost.", |
| 38 | + highlighted_skills=["Python", "SQL", "XGBoost"], |
| 39 | + priority_bullets=["Built predictive modeling workflows for fraud detection use cases."], |
| 40 | + ) |
| 41 | + tailoring_output = TailoringAgentOutput( |
| 42 | + professional_summary="Candidate profile aligned to Data Scientist with grounded evidence around Python, SQL, XGBoost.", |
| 43 | + rewritten_bullets=["Built predictive modeling workflows for fraud detection use cases."], |
| 44 | + highlighted_skills=["Python", "SQL", "XGBoost"], |
| 45 | + ) |
| 46 | + |
| 47 | + result = agent.run( |
| 48 | + candidate_profile, |
| 49 | + job_description={"title": "Data Scientist"}, |
| 50 | + fit_analysis=fit_analysis, |
| 51 | + tailored_draft=tailored_draft, |
| 52 | + tailoring_output=tailoring_output, |
| 53 | + ) |
| 54 | + |
| 55 | + assert isinstance(result, ResumeGenerationAgentOutput) |
| 56 | + assert result.professional_summary == tailoring_output.professional_summary |
| 57 | + assert result.experience_bullets == ["Built predictive modeling workflows for fraud detection use cases."] |
| 58 | + assert all("I " not in bullet for bullet in result.experience_bullets) |
0 commit comments