Add tests for base64 filesource

This commit is contained in:
nuwang
2023-02-01 00:51:19 +05:30
parent 129425abb5
commit 13d682ecad
3 changed files with 29 additions and 0 deletions
+5
View File
@@ -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
+21
View File
@@ -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)