Files
mcp-nextcloud/tests/unit/test_vector_sync_status_model.py
T
Chris CoutinhoandClaude Opus 4.8 e4d81d47d9 feat: harmonize MCP tool + userinfo page to documents/chunks model
Extend the documents-vs-chunks split to the remaining status surfaces so all
three report consistently (Deck #195):

- nc_get_vector_sync_status MCP tool + VectorSyncStatusResponse: add
  indexed_documents (distinct) and indexed_chunks; keep indexed_count as a
  deprecated alias of indexed_chunks. Reuses count_indexed.
- userinfo HTML page (/app/vector-sync/status): show Indexed Documents AND
  Indexed Chunks rows; switch its count to count_indexed (which also excludes
  placeholder points — the old raw count included them).
- /api/v1/vector-sync/status: restore indexed_count as a deprecated alias of
  indexed_chunks so existing consumers (integration tests, pre-#115 UI) keep
  working; the change is now purely additive for indexed_count.

Tests: VectorSyncStatusResponse documents/chunks/alias + zeroed defaults.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-04 20:28:44 +02:00

37 lines
1.2 KiB
Python

"""Unit tests for VectorSyncStatusResponse documents-vs-chunks fields."""
import pytest
from nextcloud_mcp_server.models.semantic import VectorSyncStatusResponse
pytestmark = pytest.mark.unit
def test_vector_sync_status_documents_and_chunks() -> None:
"""Exposes documents AND chunks; indexed_count is a deprecated chunks alias."""
response = VectorSyncStatusResponse(
indexed_documents=486,
indexed_chunks=16039,
indexed_count=16039, # deprecated alias
pending_count=2214,
status="syncing",
enabled=True,
ingest_queue="memory",
)
data = response.model_dump()
assert data["indexed_documents"] == 486
assert data["indexed_chunks"] == 16039
# Alias mirrors chunks (not documents) for back-compat.
assert data["indexed_count"] == data["indexed_chunks"]
assert data["pending_count"] == 2214
def test_vector_sync_status_defaults_zeroed() -> None:
"""New corpus fields default to 0 (disabled / pre-sync path)."""
response = VectorSyncStatusResponse(status="disabled", enabled=False)
data = response.model_dump()
assert data["indexed_documents"] == 0
assert data["indexed_chunks"] == 0
assert data["indexed_count"] == 0