Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Feb 29, 2024
1 parent d1d46a5 commit 43c9e82
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 36 deletions.
3 changes: 2 additions & 1 deletion integrations/chroma/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ module = [
"chromadb.*",
"haystack.*",
"haystack_integrations.*",
"pytest.*"
"pytest.*",
"numpy.*"
]
ignore_missing_imports = true
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from typing import Any, Dict, List, Optional, Tuple

import chromadb
from chromadb.api.types import GetResult, QueryResult, validate_where, validate_where_document
import numpy as np
from chromadb.api.types import GetResult, QueryResult, validate_where, validate_where_document
from haystack import default_from_dict, default_to_dict
from haystack.dataclasses import Document
from haystack.document_stores.types import DuplicatePolicy
Expand Down
24 changes: 12 additions & 12 deletions integrations/chroma/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ def test_to_json(self, request):
)
ds_dict = ds.to_dict()
assert ds_dict == {
'type': 'haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore',
'init_parameters': {
'collection_name': 'test_to_json',
'embedding_function': 'HuggingFaceEmbeddingFunction',
'persist_path': None,
'api_key': '1234567890',
"type": "haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore",
"init_parameters": {
"collection_name": "test_to_json",
"embedding_function": "HuggingFaceEmbeddingFunction",
"persist_path": None,
"api_key": "1234567890",
},
}

Expand All @@ -111,12 +111,12 @@ def test_from_json(self):
collection_name = "test_collection"
function_name = "HuggingFaceEmbeddingFunction"
ds_dict = {
'type': 'haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore',
'init_parameters': {
'collection_name': 'test_collection',
'embedding_function': 'HuggingFaceEmbeddingFunction',
'persist_path': None,
'api_key': '1234567890',
"type": "haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore",
"init_parameters": {
"collection_name": "test_collection",
"embedding_function": "HuggingFaceEmbeddingFunction",
"persist_path": None,
"api_key": "1234567890",
},
}

Expand Down
44 changes: 22 additions & 22 deletions integrations/chroma/tests/test_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ def test_retriever_to_json(request):
)
retriever = ChromaQueryTextRetriever(ds, filters={"foo": "bar"}, top_k=99)
assert retriever.to_dict() == {
'type': 'haystack_integrations.components.retrievers.chroma.retriever.ChromaQueryTextRetriever',
'init_parameters': {
'filters': {'foo': 'bar'},
'top_k': 99,
'document_store': {
'type': 'haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore',
'init_parameters': {
'collection_name': 'test_retriever_to_json',
'embedding_function': 'HuggingFaceEmbeddingFunction',
'persist_path': None,
'api_key': '1234567890',
"type": "haystack_integrations.components.retrievers.chroma.retriever.ChromaQueryTextRetriever",
"init_parameters": {
"filters": {"foo": "bar"},
"top_k": 99,
"document_store": {
"type": "haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore",
"init_parameters": {
"collection_name": "test_retriever_to_json",
"embedding_function": "HuggingFaceEmbeddingFunction",
"persist_path": None,
"api_key": "1234567890",
},
},
},
Expand All @@ -33,17 +33,17 @@ def test_retriever_to_json(request):
@pytest.mark.integration
def test_retriever_from_json(request):
data = {
'type': 'haystack_integrations.components.retrievers.chroma.retriever.ChromaQueryTextRetriever',
'init_parameters': {
'filters': {'bar': 'baz'},
'top_k': 42,
'document_store': {
'type': 'haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore',
'init_parameters': {
'collection_name': 'test_retriever_from_json',
'embedding_function': 'HuggingFaceEmbeddingFunction',
'persist_path': '.',
'api_key': '1234567890',
"type": "haystack_integrations.components.retrievers.chroma.retriever.ChromaQueryTextRetriever",
"init_parameters": {
"filters": {"bar": "baz"},
"top_k": 42,
"document_store": {
"type": "haystack_integrations.document_stores.chroma.document_store.ChromaDocumentStore",
"init_parameters": {
"collection_name": "test_retriever_from_json",
"embedding_function": "HuggingFaceEmbeddingFunction",
"persist_path": ".",
"api_key": "1234567890",
},
},
},
Expand Down

0 comments on commit 43c9e82

Please sign in to comment.