privateGPT/tests/fixtures/ingest_helper.py
Javier Martinez 5851b02378
feat: update llama-index + dependencies (#2092)
* chore: update libraries

* fix: mypy

* chore: more updates

* fix: mypy/black

* chore: fix docker warnings

* fix: mypy

* fix: black
2024-09-26 16:29:52 +02:00

25 lines
705 B
Python

from pathlib import Path
import pytest
from fastapi.testclient import TestClient
from private_gpt.server.ingest.ingest_router import IngestResponse
class IngestHelper:
def __init__(self, test_client: TestClient):
self.test_client = test_client
def ingest_file(self, path: Path) -> IngestResponse:
files = {"file": (path.name, path.open("rb"))}
response = self.test_client.post("/v1/ingest/file", files=files)
assert response.status_code == 200
ingest_result = IngestResponse.model_validate(response.json())
return ingest_result
@pytest.fixture
def ingest_helper(test_client: TestClient) -> IngestHelper:
return IngestHelper(test_client)