vella-backend / tests /test_handle_files.py
luanpoppe
feat: começandoa a adicionar testes com pytest
39fc36b
raw
history blame
908 Bytes
import pytest
import os
from langchain_core.documents import Document
from _utils.handle_files import return_document_list_with_llama_parser
cwd = os.getcwd()
pdf_file_url = os.path.join(cwd, "tests", "fixtures", "_pdf-uma-pagina.pdf")
class TestHandleFiles:
@pytest.mark.asyncio
async def test_return_document_list_with_llama_parser_With_wrong_keys(
self, monkeypatch
):
monkeypatch.setattr(
"_utils.handle_files.llama_parser_keys",
["abc", os.getenv("LLAMA_CLOUD_API_KEY_PEIXE")],
)
result = await return_document_list_with_llama_parser(pdf_file_url)
assert isinstance(result, list)
assert len(result) > 0
assert all(isinstance(item, Document) for item in result)
assert all(len(item.page_content) > 0 for item in result)
assert all(int(item.metadata.get("page", 0)) > 0 for item in result)