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