mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-11-29 04:17:00 +08:00
Apply the Custom Tool Execution role and beta tool format gates to the build and runtime-model endpoints, and require an authenticated user for build requests. Reuse one configuration check across create and model-building operations.
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
from galaxy import exceptions
|
|
from galaxy.app_unittest_utils.toolbox_support import BaseToolBoxTestCase
|
|
from galaxy.managers.tools import DynamicToolManager
|
|
from galaxy.tool_util_models.dynamic_tool_models import DynamicToolCreatePayload
|
|
|
|
|
|
class TestDynamicToolManager(BaseToolBoxTestCase):
|
|
def setUp(self):
|
|
super().setUp()
|
|
# Initialize toolbox
|
|
assert self.toolbox
|
|
self.dynamic_tool_manager = DynamicToolManager(self.app)
|
|
self.app.config.enable_beta_tool_formats = True
|
|
|
|
def test_create_tool(self):
|
|
tool_version = "0.1"
|
|
payload = DynamicToolCreatePayload(
|
|
representation={
|
|
"class": "GalaxyTool",
|
|
"name": "Test Tool",
|
|
"version": tool_version,
|
|
"shell_command": "echo 42",
|
|
}
|
|
)
|
|
dynamic_tool = self.dynamic_tool_manager.create_tool(payload)
|
|
assert dynamic_tool.active
|
|
assert dynamic_tool.public
|
|
assert dynamic_tool.tool_format == "GalaxyTool"
|
|
assert dynamic_tool.tool_version == tool_version
|
|
|
|
def test_create_tool_no_version(self):
|
|
payload = DynamicToolCreatePayload(
|
|
representation={"class": "GalaxyTool", "name": "Test Tool", "shell_command": "echo 42"}
|
|
)
|
|
with self.assertRaises(ValueError):
|
|
self.dynamic_tool_manager.create_tool(payload)
|
|
|
|
def test_create_tool_requires_beta_tool_formats(self):
|
|
self.app.config.enable_beta_tool_formats = False
|
|
payload = DynamicToolCreatePayload(
|
|
representation={
|
|
"class": "GalaxyTool",
|
|
"name": "Test Tool",
|
|
"version": "0.1",
|
|
"shell_command": "echo 42",
|
|
}
|
|
)
|
|
with self.assertRaises(exceptions.ConfigDoesNotAllowException):
|
|
self.dynamic_tool_manager.create_tool(payload)
|