84 lines
2.7 KiB
Python
84 lines
2.7 KiB
Python
"""Professional summary — persist fields and serializer shape. No DB."""
|
|
|
|
from types import SimpleNamespace
|
|
from uuid import uuid4
|
|
|
|
from g_sheet.scoring import serialize_form_ats
|
|
from inbox.serializers import serialize_ats_result, serialize_inbox_rescan_run
|
|
from job.candidate.plugins import candidate_completed_fields, candidate_failed_fields
|
|
|
|
|
|
def test_failed_fields_omit_professional_summary():
|
|
source = {"safe_name": "a.pdf", "file_path": None, "sha256": "x"}
|
|
fields = candidate_failed_fields(source, "PDF_TEXT_UNAVAILABLE", "empty")
|
|
assert "professional_summary" not in fields
|
|
|
|
|
|
def test_completed_fields_include_professional_summary():
|
|
result = SimpleNamespace(
|
|
candidate_name="Ada",
|
|
job_title="Engineer",
|
|
current_company="Acme",
|
|
years_experience=6,
|
|
match_score=82,
|
|
matched_keywords=["Python"],
|
|
missing_keywords=["AWS"],
|
|
summary_critique="Strong Python, missing cloud.",
|
|
professional_summary="Python backend specialist in Engineering.",
|
|
)
|
|
source = {"safe_name": "a.pdf", "file_path": None, "sha256": "x"}
|
|
fields = candidate_completed_fields(source, result)
|
|
assert fields["professional_summary"] == "Python backend specialist in Engineering."
|
|
|
|
|
|
def test_serialize_ats_result_includes_summary():
|
|
job_id = uuid4()
|
|
row = SimpleNamespace(
|
|
job_post_id=job_id,
|
|
overall_score=81.0,
|
|
band="Potential Match",
|
|
professional_summary="Python backend in Engineering.",
|
|
computed_at=None,
|
|
)
|
|
assert serialize_ats_result(row) == {
|
|
"job_post_id": str(job_id),
|
|
"overall_score": 81.0,
|
|
"band": "Potential Match",
|
|
"professional_summary": "Python backend in Engineering.",
|
|
"computed_at": None,
|
|
}
|
|
assert serialize_form_ats(row) == serialize_ats_result(row)
|
|
|
|
|
|
def test_serialize_inbox_rescan_run_includes_summaries():
|
|
run_id = uuid4()
|
|
entry = {
|
|
"kind": "email",
|
|
"record_id": str(uuid4()),
|
|
"job_post_id": str(uuid4()),
|
|
"professional_summary": "Python backend in Engineering.",
|
|
}
|
|
row = SimpleNamespace(
|
|
id=run_id,
|
|
status="completed",
|
|
channel="all",
|
|
sheet=None,
|
|
task_id=None,
|
|
created_by=None,
|
|
job_count=2,
|
|
candidate_count=1,
|
|
skipped_candidates=0,
|
|
skipped_pairs=0,
|
|
pair_count=1,
|
|
done_count=1,
|
|
summaries=[entry],
|
|
error=None,
|
|
created_at=None,
|
|
started_at=None,
|
|
finished_at=None,
|
|
)
|
|
payload = serialize_inbox_rescan_run(row)
|
|
assert payload["summaries"] == [entry]
|
|
assert payload["id"] == str(run_id)
|
|
assert payload["done_count"] == 1
|