Skip to content

Commit

Permalink
tests: upload more files (#132)
Browse files Browse the repository at this point in the history
* tests: upload more files

* chore: open new file everytime

* chor: add log statement

* fix: upload files

* fix

* fix

---------

Co-authored-by: Kristof Herrmann <[email protected]>
  • Loading branch information
wochinge and ArzelaAscoIi authored Nov 7, 2023
1 parent 057d2e2 commit 15a335e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/api/test_integration_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}

0 comments on commit 15a335e

Please sign in to comment.