From 15a335ec8bfbca5539d033e42c617d4d738d79fb Mon Sep 17 00:00:00 2001 From: Tobias Wochinger Date: Tue, 7 Nov 2023 11:56:25 +0100 Subject: [PATCH] tests: upload more files (#132) * tests: upload more files * chore: open new file everytime * chor: add log statement * fix: upload files * fix * fix --------- Co-authored-by: Kristof Herrmann --- tests/conftest.py | 6 ++++-- tests/integration/api/test_integration_files.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f6d4f961..946c624c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -35,6 +35,7 @@ def _get_file_names(integration_config: CommonConfig, workspace_name: str) -> Li ) assert list_response.status_code == HTTPStatus.OK file_names: List[str] = list_response.json()["data"] + logger.info("Found files", file_names=file_names) return file_names @@ -118,13 +119,14 @@ def workspace_name(integration_config: CommonConfig) -> str: assert response.status_code in (HTTPStatus.CREATED, HTTPStatus.CONFLICT) if len(_get_file_names(integration_config=integration_config, workspace_name=workspace_name)) == 0: - with open("tests/data/example.txt", "rb") as example_file_txt: + for i in range(15): response = httpx.post( f"{integration_config.api_url}/workspaces/{workspace_name}/files", + data={"text": "This is text"}, files={ - "file": ("example.txt", example_file_txt, "text/plain"), "meta": (None, json.dumps({"find": "me"}).encode("utf-8")), }, + params={"file_name": f"example{i}.txt"}, headers={"Authorization": f"Bearer {integration_config.api_key}"}, ) assert response.status_code == HTTPStatus.CREATED diff --git a/tests/integration/api/test_integration_files.py b/tests/integration/api/test_integration_files.py index 0cf58a27..08de89e5 100644 --- a/tests/integration/api/test_integration_files.py +++ b/tests/integration/api/test_integration_files.py @@ -11,13 +11,13 @@ async def test_list_paginated(self, integration_config: CommonConfig, workspace_ async with DeepsetCloudAPI.factory(integration_config) as deepset_cloud_api: files_api = FilesAPI(deepset_cloud_api) result = await files_api.list_paginated( - workspace_name=workspace_name, limit=10, name="example", content="text", odata_filter="find eq 'me'" + workspace_name=workspace_name, limit=10, name="example0", content="text", odata_filter="find eq 'me'" ) assert result.total == 1 assert result.has_more is False assert len(result.data) == 1 found_file = result.data[0] - assert found_file.name == "example.txt" + assert found_file.name == "example0.txt" assert found_file.size > 0 assert found_file.meta == {"find": "me"}