Skip to content

Commit

Permalink
Test hash validation also for upload by path
Browse files Browse the repository at this point in the history
  • Loading branch information
nsoranzo committed Nov 5, 2024
1 parent b97ede7 commit 1f223d0
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions test/unit/app/tools/test_data_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from contextlib import contextmanager
from shutil import rmtree
from tempfile import mkdtemp
from typing import Optional

import pytest

from galaxy.tools.data_fetch import main
from galaxy.util.unittest_utils import skip_if_github_down
Expand All @@ -13,7 +16,17 @@
URI_FOR_1_2_3 = f"base64://{B64_FOR_1_2_3}"


def test_simple_path_get():
@pytest.mark.parametrize(
"hash_value, error_message",
[
("471ddd37fc297fba09b893b88739ece9", None),
(
"thisisbad",
"Failed to validate upload with [MD5] - expected [thisisbad] got [471ddd37fc297fba09b893b88739ece9]",
),
],
)
def test_simple_path_get(hash_value: str, error_message: Optional[str]):
with _execute_context() as execute_context:
job_directory = execute_context.job_directory
example_path = os.path.join(job_directory, "example_file")
Expand All @@ -25,13 +38,30 @@ def test_simple_path_get():
"destination": {
"type": "hdas",
},
"elements": [{"src": "path", "path": example_path}],
"elements": [
{
"src": "path",
"path": example_path,
"hashes": [
{
"hash_function": "MD5",
"hash_value": hash_value,
}
],
}
],
}
]
],
"validate_hashes": True,
}
execute_context.execute_request(request)
output = _unnamed_output(execute_context)
assert output
hda_result = output["elements"][0]
if error_message is not None:
assert hda_result["error_message"] == error_message
else:
assert "error_message" not in hda_result


@skip_if_github_down
Expand Down

0 comments on commit 1f223d0

Please sign in to comment.