job-research/tests/test_storage.py
2026-05-28 13:30:01 +02:00

40 lines
1.5 KiB
Python

import pytest
from job_research.models import CandidateProfileOutput, ExperienceEntry, WarningItem
from job_research.storage import save_candidate_profile_yaml, load_yaml
def test_save_candidate_profile_yaml_round_trips_readable_output(tmp_path) -> None:
profile = CandidateProfileOutput(
name="Tonio",
summary="Junior data engineer focused on Python and GCP.",
target_roles=["Data Engineer"],
strengths=["Python", "SQL"],
skills_to_emphasize=["GCP", "BigQuery"],
constraints=["CDI only", "France only"],
notes=["Slight preference for French listings."],
location="France",
languages=["French", "English"],
skills=["Python", "SQL", "Terraform", "GCP", "BigQuery"],
experience_entries=[ExperienceEntry(company="A", title="Data Engineer")],
education_entries=[],
warnings=[WarningItem(field="years_of_experience", message="CV and profile disagree.")],
)
out = tmp_path / "candidate-profile.yaml"
save_candidate_profile_yaml(out, profile)
payload = load_yaml(out)
assert payload["name"] == "Tonio"
assert payload["constraints"] == ["CDI only", "France only"]
assert payload["warnings"][0]["field"] == "years_of_experience"
def test_load_yaml_rejects_non_mapping_root(tmp_path) -> None:
path = tmp_path / "candidate-profile.yaml"
path.write_text("[]", encoding="utf-8")
with pytest.raises(ValueError, match="mapping"):
load_yaml(path)