Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
eolivelli committed Dec 4, 2023
1 parent 76314dd commit 65bb1e2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


# LlamaHub is disabled while using RAGStack AI, because it would download unknown software from the Internet.
def disabled_download_loader():
def disabled_download_loader(*args, **kwargs):
raise ImportError(
"LlamaHub is disabled while using RAGStack AI, because it would download unknown software from the Internet.")

Expand Down
15 changes: 15 additions & 0 deletions libs/ragstack-ai-llamaindex/tests/test_ragstack_llamaindex.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
import pytest


def test_import():
from ragstack_ai_llamaindex import __version__ # noqa
from llama_index.vector_stores import AstraDBVectorStore, CassandraVectorStore # noqa
import astrapy # noqa
import cassio # noqa


def test_dont_download():
# TODO: if you don't have the llama_index package installed, this test will fail because the monkey patch is not
# executed
from ragstack_ai_llamaindex import __version__
from llama_index import download_loader
try:
download_loader("PDFReader")
pytest.fail("Should have raised an ImportError")
except ImportError as error:
assert "LlamaHub is disabled while using RAGStack AI" in str(error)

0 comments on commit 65bb1e2

Please sign in to comment.