mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-12-12 06:07:56 +00:00
Minor formatting and fix tests
This commit is contained in:
parent
bc21102cf4
commit
a0146de611
@ -21,9 +21,8 @@ config = {
|
||||
|
||||
templates = os.path.join(HERE, "templates")
|
||||
|
||||
scripts = {
|
||||
"init": ["minio-client"]
|
||||
}
|
||||
scripts = {"init": ["minio-client"]}
|
||||
|
||||
|
||||
def patches():
|
||||
all_patches = {}
|
||||
|
@ -66,6 +66,7 @@ class PluginsTests(unittest.TestCase):
|
||||
def test_configure(self):
|
||||
config = {"ID": "id"}
|
||||
defaults = {}
|
||||
|
||||
class plugin1:
|
||||
config = {
|
||||
"add": {"PARAM1": "value1", "PARAM2": "value2"},
|
||||
@ -104,6 +105,7 @@ class PluginsTests(unittest.TestCase):
|
||||
|
||||
def test_configure_set_random_string(self):
|
||||
config = {}
|
||||
|
||||
class plugin1:
|
||||
config = {"set": {"PARAM1": "{{ 128|random_string }}"}}
|
||||
|
||||
@ -116,8 +118,10 @@ class PluginsTests(unittest.TestCase):
|
||||
def test_configure_default_value_with_previous_definition(self):
|
||||
config = {}
|
||||
defaults = {"PARAM1": "value"}
|
||||
|
||||
class plugin1:
|
||||
config = {"defaults": {"PARAM2": "{{ PARAM1 }}"}}
|
||||
|
||||
with unittest.mock.patch.object(
|
||||
plugins, "iter_enabled", return_value=[("plugin1", plugin1)]
|
||||
):
|
||||
@ -127,6 +131,7 @@ class PluginsTests(unittest.TestCase):
|
||||
def test_scripts(self):
|
||||
class plugin1:
|
||||
scripts = {"init": ["myclient"]}
|
||||
|
||||
with unittest.mock.patch.object(
|
||||
plugins, "iter_enabled", return_value=[("plugin1", plugin1)]
|
||||
):
|
||||
|
@ -176,8 +176,7 @@ def https_create(root):
|
||||
fmt.echo_info("HTTPS is not activated: certificate generation skipped")
|
||||
return
|
||||
|
||||
# TODO this is not going to work anymore
|
||||
script = runner.render("certbot", "create")
|
||||
script = runner.render("scripts", "certbot", "create")
|
||||
|
||||
if config["WEB_PROXY"]:
|
||||
fmt.echo_info(
|
||||
@ -305,7 +304,16 @@ def portainer(root, port):
|
||||
|
||||
class ScriptRunner(scripts.BaseRunner):
|
||||
def exec(self, service, command):
|
||||
docker_compose(self.root, self.config, "run", "--rm", "--entrypoint", "sh -e -c", service, command)
|
||||
docker_compose(
|
||||
self.root,
|
||||
self.config,
|
||||
"run",
|
||||
"--rm",
|
||||
"--entrypoint",
|
||||
"sh -e -c",
|
||||
service,
|
||||
command,
|
||||
)
|
||||
|
||||
|
||||
def docker_compose(root, config, *command):
|
||||
|
@ -111,6 +111,7 @@ def load_required(config, defaults):
|
||||
if key not in config:
|
||||
config[key] = env.render_unknown(config, defaults[key])
|
||||
|
||||
|
||||
def load_plugins(config, defaults):
|
||||
"""
|
||||
Add, override and set new defaults from plugins.
|
||||
|
@ -160,6 +160,7 @@ def render_unknown(config, value):
|
||||
return render_str(config, value)
|
||||
return value
|
||||
|
||||
|
||||
def render_str(config, text):
|
||||
"""
|
||||
Args:
|
||||
|
@ -10,9 +10,12 @@ class BaseRunner:
|
||||
self.config = config
|
||||
|
||||
def run(self, service, *path):
|
||||
command = env.render_file(self.config, *path).strip()
|
||||
command = self.render(*path)
|
||||
self.exec(service, command)
|
||||
|
||||
def render(self, *path):
|
||||
return env.render_file(self.config, *path).strip()
|
||||
|
||||
def exec(self, service, command):
|
||||
raise NotImplementedError
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user