mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-01 15:37:32 +08:00
Add tests for base64 filesource
This commit is contained in:
@@ -28,5 +28,10 @@ class Base64FilesSource(BaseFilesSource):
|
||||
def _write_from(self, target_path, native_path, user_context=None):
|
||||
raise NotImplementedError()
|
||||
|
||||
def score_url_match(self, url: str):
|
||||
if url.startswith("base64://"):
|
||||
return len("base64://")
|
||||
else:
|
||||
return 0
|
||||
|
||||
__all__ = ("Base64FilesSource",)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
- type: base64
|
||||
id: test1
|
||||
doc: Test base64 string decoding
|
||||
@@ -0,0 +1,21 @@
|
||||
import base64
|
||||
import os
|
||||
from galaxy import util
|
||||
|
||||
from ._util import configured_file_sources, user_context_fixture, assert_realizes_as
|
||||
|
||||
SCRIPT_DIRECTORY = os.path.abspath(os.path.dirname(__file__))
|
||||
FILE_SOURCES_CONF = os.path.join(SCRIPT_DIRECTORY, "base64_file_sources_conf.yml")
|
||||
|
||||
|
||||
def test_file_source():
|
||||
ORIGINAL_STRING = "I'm a b64 encoded string"
|
||||
test_url = f"base64://{util.unicodify(base64.b64encode(util.smart_str(ORIGINAL_STRING)))}"
|
||||
user_context = user_context_fixture()
|
||||
file_sources = configured_file_sources(FILE_SOURCES_CONF)
|
||||
file_source_pair = file_sources.get_file_source_path(test_url)
|
||||
|
||||
assert file_source_pair.path == test_url
|
||||
assert file_source_pair.file_source.id == "test1"
|
||||
|
||||
assert_realizes_as(file_sources, test_url, ORIGINAL_STRING, user_context=user_context)
|
||||
Reference in New Issue
Block a user