mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Should fix this bug https://trello.com/c/TeguDYSq discovered by Bjoern... on stage at the GCC.
31 lines
876 B
Python
31 lines
876 B
Python
""" Unit test logic related to finding externally referenced files in tool
|
|
descriptions.
|
|
"""
|
|
import tempfile
|
|
import os
|
|
import shutil
|
|
from galaxy.tools import Tool
|
|
|
|
|
|
def test_finds_external_code_file():
|
|
assert __external_files("""<tool><code file="foo.py" /></tool>""") == ["foo.py"]
|
|
|
|
|
|
def test_finds_skips_empty_code_file_attribute():
|
|
assert __external_files("""<tool><code /></tool>""") == []
|
|
|
|
|
|
def test_finds_external_macro_file():
|
|
assert __external_files("""<tool><macros><import>cool_macros.xml</import></macros></tool>""") == ["cool_macros.xml"]
|
|
|
|
|
|
def __external_files(contents):
|
|
base_path = tempfile.mkdtemp()
|
|
try:
|
|
tool_path = os.path.join(base_path, "tool.xml")
|
|
with open(tool_path, "w") as f:
|
|
f.write(contents)
|
|
return Tool.get_externally_referenced_paths(tool_path)
|
|
finally:
|
|
shutil.rmtree(base_path)
|