test(cppa_youtube_script_tracker): expand coverage for services, phases, fetcher, and failure classification#200
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds new pytest coverage across the YouTube tracker: exception classification, fetcher query/formatting/pagination behavior, service persistence defaults and datetime parsing, and extensive management-command flow and error-path tests. ChangesYouTube Tracker Test Coverage
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cppa_youtube_script_tracker/tests/test_run_command.py (1)
464-477: ⚡ Quick winAdd an explicit assertion for the “resolve_speakers returns empty” path.
Right now this test only verifies no exception. Add a before/after link count assertion so regressions in link creation are caught.
Proposed enhancement
`@pytest.mark.django_db` def test_enrich_speakers_from_transcript_resolve_empty(monkeypatch, tmp_path): @@ tr = tmp_path / "some.vtt" tr.write_text("WEBVTT\n\nnote\n", encoding="utf-8") monkeypatch.setattr(f"{_CMD}.resolve_speakers", lambda **_k: []) + from cppa_youtube_script_tracker.models import YouTubeVideoSpeaker + before = YouTubeVideoSpeaker.objects.filter(video=video).count() _enrich_speakers_from_transcript(video, str(tr)) + assert YouTubeVideoSpeaker.objects.filter(video=video).count() == before🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cppa_youtube_script_tracker/tests/test_run_command.py` around lines 464 - 477, The test test_enrich_speakers_from_transcript_resolve_empty should assert that no new speaker links are created when resolve_speakers returns an empty list: record the initial count of any related link model (e.g., count of speaker/video links or YouTubeVideo.speakers relation) before calling _enrich_speakers_from_transcript(video, str(tr)), then call the function and assert the count is unchanged afterwards; reference the test name, the monkeypatched resolve_speakers, and the target function _enrich_speakers_from_transcript to locate where to add the before/after assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cppa_youtube_script_tracker/tests/test_run_command.py`:
- Around line 579-590: The test assigns the return tuple from _persist_video to
a variable named created that is never used, causing RUF059; update the
assignment to use a throwaway name like _created or _ (e.g., change "created,
skipped = _persist_video(...)" to "_created, skipped = _persist_video(...)" or
"_, skipped = _persist_video(...)" ) so the unused value is ignored while
leaving the call to _persist_video and subsequent assertion on skipped
unchanged.
---
Nitpick comments:
In `@cppa_youtube_script_tracker/tests/test_run_command.py`:
- Around line 464-477: The test
test_enrich_speakers_from_transcript_resolve_empty should assert that no new
speaker links are created when resolve_speakers returns an empty list: record
the initial count of any related link model (e.g., count of speaker/video links
or YouTubeVideo.speakers relation) before calling
_enrich_speakers_from_transcript(video, str(tr)), then call the function and
assert the count is unchanged afterwards; reference the test name, the
monkeypatched resolve_speakers, and the target function
_enrich_speakers_from_transcript to locate where to add the before/after
assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7f162c43-0135-420b-a1d2-fb684d6ad17f
📒 Files selected for processing (4)
cppa_youtube_script_tracker/tests/test_failure_classification.pycppa_youtube_script_tracker/tests/test_fetcher.pycppa_youtube_script_tracker/tests/test_run_command.pycppa_youtube_script_tracker/tests/test_services.py
Summary
Adds and extends tests for
cppa_youtube_script_trackerso services, management command phases, YouTube Data API fetcher paths, andclassify_failurebehavior are covered without real network oryt-dlpruns (mocks/stubs only).Scope
download_vttNone/exception),_persist_fetched_video/_process_queueerror paths, transcript enrichment edge cases, Pinecone skip paths, stdout messaging, dry-runsync_pinecone.nextPageToken), thin/malformed API payloads, dedupe, searchNonebreak.classify_failuremappings forValueError,ImportError,QuotaExceededError, andgoogleapiclient.errors.HttpError(UNKNOWN) per existingcore/errors.py.How tested
pytest cppa_youtube_script_tracker/tests/Notes
Checklist
yt-dlpin tests--cov-fail-under=90)Closes #185
Summary by CodeRabbit