refactor(test): share the Qdrant point-seeding helper

Why:
- The helper turning a SeedSpec into an upsertable ChunkPoint lived inside one
  integration test. A second suite now needs to seed real Qdrant the same way,
  and a copy would let the two drift.

Changes:
- Move `_chunk_point` into tests/support/point_contract.py as `chunk_point_for`,
  beside the `build_point` read model it derives its payload from.

Impact:
- Pure move. No behaviour change; enables the API suite that follows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-22 15:08:25 +03:30
parent 923ac8e5d6
commit 062fdd7ac1
2 changed files with 29 additions and 29 deletions

View File

@@ -21,8 +21,14 @@ from dataclasses import dataclass
from datetime import UTC, datetime
from src.application.ingestion.chunking import chunk_id_for
from src.application.ingestion.models import SparseVector
from src.application.points.models import ChunkPoint
from src.application.points.point import Point
from src.application.ports.point_repository import PayloadPatch, PointRepository
from src.infrastructure.qdrant.collection import (
DENSE_NOMIC_DIMENSIONS,
DENSE_OPENAI_DIMENSIONS,
)
# Two tenants and two files, so every scenario can assert both that the right
# rows come back and that the wrong ones do not.
@@ -76,6 +82,26 @@ def build_point(spec: SeedSpec) -> Point:
)
def chunk_point_for(spec: SeedSpec) -> ChunkPoint:
"""A `SeedSpec` as something upsertable into real Qdrant.
The payload is taken straight off `build_point`'s read model rather than
hand-written, so the write shape and the read shape cannot drift apart. The
vectors are constant filler: nothing in plan 002's read paths scores by
similarity, so their values are irrelevant and their dimensions are not.
"""
point = build_point(spec)
return ChunkPoint(
point_id=point.point_id,
dense={
"dense_nomic": [0.1] * DENSE_NOMIC_DIMENSIONS,
"dense_openai": [0.2] * DENSE_OPENAI_DIMENSIONS,
},
sparse=SparseVector(indices=[1, 2], values=[0.5, 0.25]),
payload=point.model_dump(mode="json", exclude={"point_id", "vectors"}),
)
def seed_specs(
tenant_a: uuid.UUID,
tenant_b: uuid.UUID,