mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-02 08:44:44 +00:00
Use actual http request for test
This commit is contained in:
parent
da035d69cf
commit
acdf4cd73a
1 changed files with 6 additions and 10 deletions
|
@ -10,7 +10,6 @@ import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from pytest_httpx import HTTPXMock
|
|
||||||
|
|
||||||
from llama_stack.apis.memory.memory import MemoryBankDocument, URL
|
from llama_stack.apis.memory.memory import MemoryBankDocument, URL
|
||||||
from llama_stack.providers.utils.memory.vector_store import content_from_doc
|
from llama_stack.providers.utils.memory.vector_store import content_from_doc
|
||||||
|
@ -35,7 +34,6 @@ def data_url_from_file(file_path: str) -> str:
|
||||||
return data_url
|
return data_url
|
||||||
|
|
||||||
|
|
||||||
# Requires pytest-httpx - pip install pytest-httpx
|
|
||||||
class TestVectorStore:
|
class TestVectorStore:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_returns_content_from_pdf_data_uri(self):
|
async def test_returns_content_from_pdf_data_uri(self):
|
||||||
|
@ -50,9 +48,9 @@ class TestVectorStore:
|
||||||
assert content == "Dummy PDF file"
|
assert content == "Dummy PDF file"
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_downloads_pdf_and_returns_content(self, httpx_mock: HTTPXMock):
|
async def test_downloads_pdf_and_returns_content(self):
|
||||||
url = "https://example.com/dummy.pdf"
|
# Using GitHub to host the PDF file
|
||||||
httpx_mock.add_response(url=url, content=read_file(DUMMY_PDF_PATH))
|
url = "https://raw.githubusercontent.com/meta-llama/llama-stack/da035d69cfca915318eaf485770a467ca3c2a238/llama_stack/providers/tests/memory/fixtures/dummy.pdf"
|
||||||
doc = MemoryBankDocument(
|
doc = MemoryBankDocument(
|
||||||
document_id="dummy",
|
document_id="dummy",
|
||||||
content=url,
|
content=url,
|
||||||
|
@ -63,11 +61,9 @@ class TestVectorStore:
|
||||||
assert content == "Dummy PDF file"
|
assert content == "Dummy PDF file"
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_downloads_pdf_and_returns_content_with_url_object(
|
async def test_downloads_pdf_and_returns_content_with_url_object(self):
|
||||||
self, httpx_mock: HTTPXMock
|
# Using GitHub to host the PDF file
|
||||||
):
|
url = "https://raw.githubusercontent.com/meta-llama/llama-stack/da035d69cfca915318eaf485770a467ca3c2a238/llama_stack/providers/tests/memory/fixtures/dummy.pdf"
|
||||||
url = "https://example.com/dummy.pdf"
|
|
||||||
httpx_mock.add_response(url=url, content=read_file(DUMMY_PDF_PATH))
|
|
||||||
doc = MemoryBankDocument(
|
doc = MemoryBankDocument(
|
||||||
document_id="dummy",
|
document_id="dummy",
|
||||||
content=URL(
|
content=URL(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue