Skip to content

Commit

Permalink
test: fix tests to check file content
Browse files Browse the repository at this point in the history
  • Loading branch information
dreinon committed May 26, 2022
1 parent 1217cba commit 7995837
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions tests/_async/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def file(tmp_path: Path, uuid_factory: Callable[[], str]) -> dict[str, str]:
"bucket_folder": bucket_folder,
"bucket_path": bucket_path,
"mime_type": "image/svg+xml",
"file_content": file_content,
}


Expand All @@ -119,14 +120,16 @@ async def test_client_upload_file(
file_name = file["name"]
file_path = file["local_path"]
mime_type = file["mime_type"]
file_content = file["file_content"]
bucket_file_path = file["bucket_path"]
bucket_folder = file["bucket_folder"]
options = {"content-type": mime_type}

await storage_file_client.upload(bucket_file_path, file_path, options)

image = await storage_file_client.download(bucket_file_path)
files = await storage_file_client.list(bucket_folder)
image_info = next((f for f in files if f.get("name") == file_name), None)

assert files
assert image_info is not None
assert image == file_content
assert image_info.get("metadata", {}).get("mimetype") == mime_type
7 changes: 5 additions & 2 deletions tests/_sync/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def file(tmp_path: Path, uuid_factory: Callable[[], str]) -> dict[str, str]:
"bucket_folder": bucket_folder,
"bucket_path": bucket_path,
"mime_type": "image/svg+xml",
"file_content": file_content,
}


Expand All @@ -119,14 +120,16 @@ def test_client_upload_file(
file_name = file["name"]
file_path = file["local_path"]
mime_type = file["mime_type"]
file_content = file["file_content"]
bucket_file_path = file["bucket_path"]
bucket_folder = file["bucket_folder"]
options = {"content-type": mime_type}

storage_file_client.upload(bucket_file_path, file_path, options)

image = storage_file_client.download(bucket_file_path)
files = storage_file_client.list(bucket_folder)
image_info = next((f for f in files if f.get("name") == file_name), None)

assert files
assert image_info is not None
assert image == file_content
assert image_info.get("metadata", {}).get("mimetype") == mime_type

0 comments on commit 7995837

Please sign in to comment.