|
3 | 3 | import pytest |
4 | 4 |
|
5 | 5 | from mindee.v2.client import Client |
6 | | -from mindee.v2.search.rag_documents.rag_document_search_parameters import ( |
7 | | - RagDocumentSearchParameters, |
8 | | -) |
| 6 | +from mindee.v2.search.rag_documents import RagDocumentSearchParameters |
9 | 7 |
|
10 | 8 |
|
11 | 9 | @pytest.fixture(scope="session") |
12 | 10 | def v2_client() -> Client: |
13 | 11 | return Client() |
14 | 12 |
|
15 | 13 |
|
16 | | -@pytest.mark.integration |
17 | | -@pytest.mark.v2 |
18 | | -def test_must_have_results(v2_client: Client): |
| 14 | +@pytest.fixture(scope="session") |
| 15 | +def findoc_model_id() -> str: |
19 | 16 | findoc_model_id = os.getenv("MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID") |
20 | 17 | assert findoc_model_id, "MINDEE_V2_SE_TESTS_FINDOC_MODEL_ID must be set" |
| 18 | + return findoc_model_id |
| 19 | + |
| 20 | + |
| 21 | +@pytest.mark.integration |
| 22 | +@pytest.mark.v2 |
| 23 | +def test_search_must_have_results(v2_client: Client, findoc_model_id: str): |
21 | 24 | response = v2_client.search(RagDocumentSearchParameters(model_id=findoc_model_id)) |
22 | 25 |
|
23 | 26 | assert response is not None |
24 | 27 | assert len(response.rag_documents) > 0 |
| 28 | + for rag_doc in response.rag_documents: |
| 29 | + assert rag_doc.id |
| 30 | + assert rag_doc.created_at |
| 31 | + assert rag_doc.filename |
| 32 | + assert rag_doc.total_matches >= 0 |
25 | 33 | assert response.pagination is not None |
26 | 34 | assert response.pagination.total_items >= 1 |
27 | 35 | assert response.pagination.page == 1 |
| 36 | + |
| 37 | + |
| 38 | +@pytest.mark.integration |
| 39 | +@pytest.mark.v2 |
| 40 | +def test_search_must_return_empty(v2_client: Client, findoc_model_id: str): |
| 41 | + response = v2_client.search( |
| 42 | + RagDocumentSearchParameters( |
| 43 | + model_id=findoc_model_id, filename="invoice_32GB-RAM_450k-USD.pdf" |
| 44 | + ) |
| 45 | + ) |
| 46 | + |
| 47 | + assert response is not None |
| 48 | + assert len(response.rag_documents) == 0 |
| 49 | + assert response.pagination is not None |
| 50 | + assert response.pagination.total_items == 0 |
| 51 | + assert response.pagination.page == 1 |
0 commit comments