forked from HAL9000/cleveragents-core
31472b5413
Add Behave feature/step pairs that exercise uncovered branches across handlers, LSP, CLI, and service layers to reach the coverage gate. ISSUES CLOSED: #1232
126 lines
6.0 KiB
Gherkin
126 lines
6.0 KiB
Gherkin
@mock_only
|
|
Feature: FAISS vector backend uncovered paths (fvcov3)
|
|
As a test author
|
|
I want to exercise edge-case and error paths in the FAISS vector backend
|
|
So that code coverage improves for faiss_vector_backend.py
|
|
|
|
# --- _require_non_empty validation (line 28) ---
|
|
|
|
Scenario: Indexing with empty project raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I index embedding with empty project and doc_id "doc1" and vector "1.0,0.0"
|
|
Then fvcov3 the error message should contain "project must be a non-empty string"
|
|
|
|
Scenario: Indexing with whitespace-only doc_id raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I index embedding with project "proj" and doc_id " " and vector "1.0,0.0"
|
|
Then fvcov3 the error message should contain "doc_id must be a non-empty string"
|
|
|
|
# --- similarity_search empty embedding (line 48) ---
|
|
|
|
Scenario: Similarity search with empty embedding raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorBackend backed by it
|
|
When fvcov3 I similarity search with empty embedding
|
|
Then fvcov3 the error message should contain "embedding must be a non-empty list"
|
|
|
|
# --- similarity_search top_k < 1 (line 50) ---
|
|
|
|
Scenario: Similarity search with top_k zero raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorBackend backed by it
|
|
When fvcov3 I similarity search with top_k 0
|
|
Then fvcov3 the error message should contain "top_k must be positive"
|
|
|
|
# --- similarity_search skips hits without doc_id (line 62) ---
|
|
|
|
Scenario: Similarity search skips hits with missing doc_id
|
|
Given fvcov3 a mock vector store service that returns hits without doc_id
|
|
And fvcov3 a FAISSVectorBackend backed by it
|
|
When fvcov3 I perform a valid similarity search
|
|
Then fvcov3 the similarity search results should be empty
|
|
|
|
# --- index_embedding empty embedding (line 92) ---
|
|
|
|
Scenario: Index embedding with empty embedding raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I index embedding with project "proj" and doc_id "doc1" and empty embedding
|
|
Then fvcov3 the error message should contain "embedding must be a non-empty list"
|
|
|
|
# --- index_embedding metadata fallback to resource_type (line 95) ---
|
|
|
|
Scenario: Index embedding uses resource_type when location is absent
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I index embedding with metadata having resource_type "python_file" but no location
|
|
Then fvcov3 the indexed content should be "python_file"
|
|
|
|
Scenario: Index embedding uses default payload when neither location nor resource_type exists
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I index embedding with empty metadata for doc_id "my-doc"
|
|
Then fvcov3 the indexed content should be "embedding:my-doc"
|
|
|
|
# --- search_similar empty query_embedding (line 116) ---
|
|
|
|
Scenario: Search similar with empty query embedding raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I search similar with empty query embedding in project "proj"
|
|
Then fvcov3 the error message should contain "query_embedding must be a non-empty list"
|
|
|
|
# --- search_similar limit < 1 (line 118) ---
|
|
|
|
Scenario: Search similar with limit zero raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I search similar with limit 0 in project "proj"
|
|
Then fvcov3 the error message should contain "limit must be positive"
|
|
|
|
# --- search_similar min_relevance out of range (lines 120-121) ---
|
|
|
|
Scenario: Search similar with negative min_relevance raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I search similar with min_relevance -0.5 in project "proj"
|
|
Then fvcov3 the error message should contain "min_relevance must be in [0.0, 1.0]"
|
|
|
|
Scenario: Search similar with min_relevance above 1 raises ValueError
|
|
Given fvcov3 a mock vector store service
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I search similar with min_relevance 1.5 in project "proj"
|
|
Then fvcov3 the error message should contain "min_relevance must be in [0.0, 1.0]"
|
|
|
|
# --- search_similar skips hits below min_relevance (line 133) ---
|
|
|
|
Scenario: Search similar filters out hits below min_relevance
|
|
Given fvcov3 a mock vector store service that returns hits with low scores
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I search similar with min_relevance 0.8 in project "proj"
|
|
Then fvcov3 the search similar results should be empty
|
|
|
|
# --- search_similar skips hits without doc_id (line 137) ---
|
|
|
|
Scenario: Search similar skips hits with missing doc_id
|
|
Given fvcov3 a mock vector store service that returns search hits without doc_id
|
|
And fvcov3 a FAISSVectorIndexBackend backed by it
|
|
When fvcov3 I search similar with min_relevance 0.0 in project "proj"
|
|
Then fvcov3 the search similar results should be empty
|
|
|
|
# --- build_vector_backend non-faiss fallback (lines 164-167, 169) ---
|
|
|
|
Scenario: build_vector_backend falls back to InMemoryVectorBackend for non-faiss backend
|
|
Given fvcov3 a mock vector store service with backend name "memory"
|
|
When fvcov3 I call build_vector_backend
|
|
Then fvcov3 the result should be an InMemoryVectorBackend
|
|
|
|
# --- build_vector_index_backend non-faiss fallback (lines 184-187, 189) ---
|
|
|
|
Scenario: build_vector_index_backend falls back to InMemoryVectorIndexBackend for non-faiss backend
|
|
Given fvcov3 a mock vector store service with backend name "memory"
|
|
When fvcov3 I call build_vector_index_backend
|
|
Then fvcov3 the result should be an InMemoryVectorIndexBackend
|