mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-11 02:33:51 +08:00
test(entities): add zero vector validation tests
Add comprehensive test coverage for zero and near-zero vector detection in SemanticChunk embedding validation. Solution-ID: SOL-20251228113612 Issue-ID: ISS-1766921318981-7 Task-ID: T2
This commit is contained in:
@@ -84,6 +84,24 @@ class TestSemanticChunk:
|
|||||||
chunk = SemanticChunk(content="code", embedding=embedding)
|
chunk = SemanticChunk(content="code", embedding=embedding)
|
||||||
assert chunk.embedding == embedding
|
assert chunk.embedding == embedding
|
||||||
|
|
||||||
|
def test_chunk_zero_vector_validation(self):
|
||||||
|
"""Test that zero vector embeddings are rejected."""
|
||||||
|
with pytest.raises(ValidationError) as exc:
|
||||||
|
SemanticChunk(content="code", embedding=[0.0, 0.0, 0.0, 0.0])
|
||||||
|
assert "zero vector" in str(exc.value).lower()
|
||||||
|
|
||||||
|
def test_chunk_near_zero_vector_validation(self):
|
||||||
|
"""Test that near-zero vector embeddings are rejected."""
|
||||||
|
with pytest.raises(ValidationError) as exc:
|
||||||
|
SemanticChunk(content="code", embedding=[1e-11, 1e-11, 1e-11])
|
||||||
|
assert "zero vector" in str(exc.value).lower()
|
||||||
|
|
||||||
|
def test_chunk_small_nonzero_vector_validation(self):
|
||||||
|
"""Test that small but non-zero embeddings are allowed."""
|
||||||
|
embedding = [0.001, 0.001, 0.001]
|
||||||
|
chunk = SemanticChunk(content="code", embedding=embedding)
|
||||||
|
assert chunk.embedding == embedding
|
||||||
|
|
||||||
|
|
||||||
class TestIndexedFile:
|
class TestIndexedFile:
|
||||||
"""Tests for IndexedFile entity."""
|
"""Tests for IndexedFile entity."""
|
||||||
|
|||||||
Reference in New Issue
Block a user