Bakalarska_praca/tests/fixtures/ingest_helper.py
oleh 959a391334
Some checks failed
publish docs / publish-docs (push) Has been cancelled
release-please / release-please (push) Has been cancelled
tests / setup (push) Has been cancelled
tests / ${{ matrix.quality-command }} (black) (push) Has been cancelled
tests / ${{ matrix.quality-command }} (mypy) (push) Has been cancelled
tests / ${{ matrix.quality-command }} (ruff) (push) Has been cancelled
tests / test (push) Has been cancelled
tests / all_checks_passed (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
add self code
2024-09-27 18:52:16 +02:00

25 lines
707 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)