study-buddy / tests /test_explicit_profile_capture.py
GitHub Actions
deploy d092bea3608b7a29952f16357fda39b7a29e399b
2e818da
Raw
History Blame Contribute Delete
1.19 kB
import pytest
from app.services import approved_profile_staging
from app.services.explicit_profile_capture import capture_explicit_profile_signal
@pytest.mark.asyncio
async def test_capture_stages_approved_name_candidate(tmp_path, monkeypatch):
monkeypatch.setattr(approved_profile_staging, "_ROOT", tmp_path)
await capture_explicit_profile_signal(
project_id="project-a", interaction_id="interaction-1", user_text="Please call me Anshuman.",
)
candidates, _, _ = approved_profile_staging.read_pending("project-a")
assert len(candidates) == 1
assert candidates[0].kind == "preferred_name"
assert candidates[0].attribution == "explicit_student"
assert candidates[0].interaction_ids == ["interaction-1"]
@pytest.mark.asyncio
async def test_capture_does_nothing_when_no_name_pattern_matches(tmp_path, monkeypatch):
monkeypatch.setattr(approved_profile_staging, "_ROOT", tmp_path)
await capture_explicit_profile_signal(
project_id="project-a", interaction_id="interaction-1", user_text="I am confused about robotics.",
)
candidates, _, _ = approved_profile_staging.read_pending("project-a")
assert candidates == []