Skip to content

Commit

Permalink
add check for directory label
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-1991 committed Apr 17, 2024
1 parent 61fc630 commit c4b40bc
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions tests/integration/test_native_upload.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from io import BytesIO
import json
import tempfile

import pytest
Expand Down Expand Up @@ -42,17 +43,18 @@ def test_native_upload(
)

# Assert
expected_files = [
"small_file.txt",
"mid_file.txt",
"large_file.txt",
]
files = retrieve_dataset_files(
dataverse_url=BASE_URL,
persistent_id=pid,
api_token=API_TOKEN,
)

expected_files = [
"small_file.txt",
"mid_file.txt",
"large_file.txt",
]

assert len(files) == 3
assert sorted([file["label"] for file in files]) == sorted(expected_files)

Expand Down Expand Up @@ -89,17 +91,18 @@ def test_forced_native_upload(
)

# Assert
expected_files = [
"small_file.txt",
"mid_file.txt",
"large_file.txt",
]
files = retrieve_dataset_files(
dataverse_url=BASE_URL,
persistent_id=pid,
api_token=API_TOKEN,
)

expected_files = [
"small_file.txt",
"mid_file.txt",
"large_file.txt",
]

assert len(files) == 3
assert sorted([file["label"] for file in files]) == sorted(expected_files)

Expand Down Expand Up @@ -134,15 +137,22 @@ def test_native_upload_by_handler(
)

# Assert
expected_files = [
"file.txt",
"biggerfile.txt",
expected = [
("", "biggerfile.txt"),
("subdir", "file.txt"),
]

files = retrieve_dataset_files(
dataverse_url=BASE_URL,
persistent_id=pid,
api_token=API_TOKEN,
)

assert len(files) == 2
assert sorted([file["label"] for file in files]) == sorted(expected_files)

for ex_dir, ex_f in expected:

file = next(file for file in files if file["label"] == ex_f)

assert file["label"] == ex_f, f"File label does not match for file {json.dumps(file)}"
assert file.get("directoryLabel", "") == ex_dir, f"Directory label does not match for file {json.dumps(file)}"

0 comments on commit c4b40bc

Please sign in to comment.