test: achieve 100% test coverage - #21
Conversation
- Added pytest-cov to dependencies - Added test suites for missing coverage in ingestion, sessioning, clustering, openai_compat, cli, pipeline, text, and service modules - Fixed minor div-by-zero risk handling assertion in avg_vectors logic - Attained 100% total coverage
📝 WalkthroughSummary by CodeRabbit릴리스 노트
Walkthrough클러스터링 로직에서 평균 계산 및 페널티 처리가 변경되었고, 의존성 구성이 Changes
Sequence Diagram(s)(생성 조건 미충족 — 변경은 주로 로직/테스트/구성으로, 다중 컴포넌트 연속 흐름 시각화가 필요하지 않음.) Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 시
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pyproject.toml`:
- Around line 82-86: The repo mixes dev dependency locations: pytest-cov was
added under [dependency-groups] while pytest remains under
[project.optional-dependencies].dev; choose and apply one consistent approach —
either move "pytest-cov" from [dependency-groups] into the existing
[project.optional-dependencies].dev list to keep the current layout, or migrate
all dev packages (including "pytest") into the [dependency-groups] section per
PEP 735; update the same unique identifiers ("pytest-cov", "pytest",
[dependency-groups], [project.optional-dependencies].dev) accordingly and remove
the redundant entry so all dev deps live in one place.
In `@tests/test_coverage_gap.py`:
- Around line 90-100: Add clarifying comments to both functions to document
their intentional, differing handling of boolean counts: in
build_digest_counts_all_pairs annotate why bools are treated via int(True)==1
(so True counts as 1) and in aggregate_session_topic_counts annotate why boolean
values are coerced to 0 there; locate the functions
build_digest_counts_all_pairs and aggregate_session_topic_counts and add short
docstring or inline comment describing the design decision and expected behavior
(referencing the test expectation in test_build_digest_counts_all_pairs) so
future readers understand the deliberate discrepancy.
In `@tests/test_coverage_remaining.py`:
- Around line 35-69: Remove the unused monkeypatch fixture from the test
function signature: update test_pipeline_unassigned to no longer accept the
monkeypatch parameter (it is never used), leaving the body unchanged so it still
constructs TopicModeler, calls _resolve_assignment_topic_id and
_build_session_topic_counts, and asserts expected behavior; also remove any
local references to monkeypatch if present and run tests to ensure no
fixture-related failures.
- Around line 17-33: Remove the unused pytest fixture parameter by deleting the
unused "monkeypatch" argument from the test_cli_errors function signature; open
the test_cli_errors function (symbol: test_cli_errors) and change its definition
to take no parameters since the test uses unittest.mock.patch and does not use
the monkeypatch fixture, then run the tests to ensure no other references rely
on that fixture.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e83ae986-76b1-49de-84aa-9bf54b28ade7
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
pyproject.tomlsrc/vector_topic_modeling/clustering.pytests/test_coverage_clustering.pytests/test_coverage_gap.pytests/test_coverage_openai.pytests/test_coverage_remaining.py
💤 Files with no reviewable changes (1)
- src/vector_topic_modeling/clustering.py
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai resolve |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/test_coverage_gap.py`:
- Around line 94-100: The import block for pick_session_main_digest,
build_digest_counts_all_pairs, aggregate_session_topic_counts,
pick_sample_sessions_for_topics, and build_digest_counts_session_main_pair is
located mid-file; move that entire from vector_topic_modeling.sessioning
import(...) statement up into the module's top-level imports section (the file's
import group) so imports obey PEP8 and appear with other top-of-file imports.
In `@tests/test_coverage_remaining.py`:
- Around line 1-11: Remove the unused imports Path and json from the import
block so the test file only imports what it uses; edit the import line that
currently includes Path and json (alongside pytest, argparse, patch, and the
project symbols like redact_pii_and_secrets, main, TopicModeler,
previous_period, build_qa_pair_text) to drop Path and json to eliminate the
unused-import warnings.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2aa0578f-e598-484d-a0a3-737f7133450a
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
.github/workflows/ci.yml.github/workflows/publish.yml.github/workflows/release.ymlpyproject.tomlsrc/vector_topic_modeling/sessioning.pytests/test_coverage_gap.pytests/test_coverage_remaining.py
✅ Actions performedComments resolved and changes approved. |
|
@coderabbitai resolve |
✅ Actions performedComments resolved and changes approved. |
Description
📝 Walkthrough
Summary by CodeRabbit
릴리스 노트
버그 수정
테스트
Chores
Walkthrough
클러스터링 로직에서 평균 계산 및 페널티 처리가 변경되었고, 의존성 구성이
[dependency-groups]로 이동 및pytest-cov추가되었습니다. 다수의 새로운 엣지케이스 테스트와 워크플로우의 의존성 동기화 플래그 제거가 포함됩니다.Changes
pyproject.toml[project.optional-dependencies]→[dependency-groups]로 이동;dev그룹에pytest-cov>=7.1.0추가; 공백 라인 조정.src/vector_topic_modeling/clustering.py_avg_vectors: 음수 가중치 조기 반환 제거해 항상 평균 계산 수행 (prev_weight 클램핑 유지).adaptive_greedy_cluster: max_k 초과 시 적용되던 페널티 항 제거 — 군집 선택/타이브레이크 흐름 변경 가능. (주의: 알고리즘적 동작 변경)src/vector_topic_modeling/sessioning.pybuild_digest_counts_all_pairs에서bool을 정수로 처리(True→1).aggregate_session_topic_counts에서bool을 0으로 취급해 집계에 기여하지 않도록 변경.tests/test_coverage_clustering.pyadaptive_greedy_cluster등 엣지 케이스 검증용 테스트 추가 — 클러스터 수 제약 관련 동작 검사 포함.tests/test_coverage_gap.pytests/test_coverage_openai.pytests/test_coverage_remaining.py.github/workflows/...(ci.yml, publish.yml, release.yml)uv sync --extra dev→uv sync로 변경(개발 extras 미포함).Sequence Diagram(s)
(생성 조건 미충족 — 변경은 주로 로직/테스트/구성으로, 다중 컴포넌트 연속 흐름 시각화가 필요하지 않음.)
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
시