mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Don't skip and fix TestCliInterface unit tests in app package
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
"""
|
||||
"""
|
||||
import importlib
|
||||
import json
|
||||
import pkgutil
|
||||
from glob import glob
|
||||
from os import getcwd
|
||||
from os.path import (
|
||||
basename,
|
||||
join
|
||||
)
|
||||
|
||||
from galaxy.util.plugin_config import plugins_dict
|
||||
|
||||
DEFAULT_SHELL_PLUGIN = 'LocalShell'
|
||||
|
||||
@@ -22,45 +16,13 @@ class CliInterface:
|
||||
them to specified parameters.
|
||||
"""
|
||||
|
||||
def __init__(self, code_dir='lib'):
|
||||
def __init__(self):
|
||||
"""
|
||||
"""
|
||||
def __load_from_code_dir(module_path):
|
||||
module_pattern = join(join(getcwd(), code_dir, *module_path.split('.')), '*.py')
|
||||
for file in glob(module_pattern):
|
||||
if basename(file).startswith('_'):
|
||||
continue
|
||||
module_name = f"{module_path}.{basename(file).rsplit('.py', 1)[0]}"
|
||||
module = __import__(module_name)
|
||||
for comp in module_name.split(".")[1:]:
|
||||
module = getattr(module, comp)
|
||||
yield module
|
||||
|
||||
def __load_from_path(module_path):
|
||||
base_module = importlib.import_module(module_path)
|
||||
for module_info in pkgutil.iter_modules(base_module.__path__):
|
||||
module = importlib.import_module(f'{module_path}.{module_info.name}')
|
||||
yield module
|
||||
|
||||
def __load(module_path, d):
|
||||
if code_dir is not None:
|
||||
module_generator = __load_from_code_dir
|
||||
else:
|
||||
module_generator = __load_from_path
|
||||
for module in module_generator(module_path):
|
||||
for name in module.__all__:
|
||||
try:
|
||||
d[name] = getattr(module, name)
|
||||
except TypeError:
|
||||
raise TypeError(f"Invalid type for name {name}")
|
||||
|
||||
self.cli_shells = {}
|
||||
self.cli_job_interfaces = {}
|
||||
self.active_cli_shells = {}
|
||||
|
||||
module_prefix = self.__module__
|
||||
__load(f'{module_prefix}.shell', self.cli_shells)
|
||||
__load(f'{module_prefix}.job', self.cli_job_interfaces)
|
||||
self.cli_shells = plugins_dict(f"{module_prefix}.shell", "__name__")
|
||||
self.cli_job_interfaces = plugins_dict(f"{module_prefix}.job", "__name__")
|
||||
self.active_cli_shells = {}
|
||||
|
||||
def get_plugins(self, shell_params, job_params):
|
||||
"""
|
||||
|
||||
@@ -3,17 +3,15 @@ try:
|
||||
CliInterface,
|
||||
split_params
|
||||
)
|
||||
code_dir = 'lib'
|
||||
except ImportError:
|
||||
from pulsar.managers.util.cli import ( # type: ignore[no-redef]
|
||||
CliInterface,
|
||||
split_params
|
||||
)
|
||||
code_dir = '.'
|
||||
|
||||
|
||||
def build_cli_interface():
|
||||
return CliInterface(code_dir=code_dir)
|
||||
return CliInterface()
|
||||
|
||||
|
||||
def get_shell(params):
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
mock-ssh-server
|
||||
pytest
|
||||
testfixtures
|
||||
|
||||
Reference in New Issue
Block a user