Ejemplo n.º 1
0
    def test_render_file(self) -> None:
        config: Config = {}
        tutor_config.update_with_base(config)
        tutor_config.update_with_defaults(config)
        tutor_config.render_full(config)

        config["MYSQL_ROOT_PASSWORD"] = "******"
        rendered = env.render_file(config, "hooks", "mysql", "init")
        self.assertIn("testpassword", rendered)
Ejemplo n.º 2
0
    def test_configure_set_random_string(self) -> None:
        class plugin1:
            config: Config = {"set": {"PARAM1": "{{ 128|random_string }}"}}

        with patch.object(
                plugins.Plugins,
                "iter_enabled",
                return_value=[plugins.BasePlugin("plugin1", plugin1)],
        ):
            config = tutor_config.get_base({})
        tutor_config.render_full(config)

        self.assertEqual(128, len(get_typed(config, "PARAM1", str)))
Ejemplo n.º 3
0
    def test_configure_set_random_string(self) -> None:
        plugins_v0.DictPlugin({
            "name": "plugin1",
            "config": {
                "set": {
                    "PARAM1": "{{ 128|random_string }}"
                }
            },
        })
        plugins.load("plugin1")
        config = tutor_config.get_base()
        tutor_config.render_full(config)

        self.assertEqual(128, len(get_typed(config, "PARAM1", str)))
Ejemplo n.º 4
0
    def test_config_load_from_plugins(self) -> None:
        config: Config = {}

        class plugin1:
            config: Config = {"add": {"PARAM1": "{{ 10|random_string }}"}}

        with patch.object(
                plugins.Plugins,
                "iter_enabled",
                return_value=[plugins.BasePlugin("plugin1", plugin1)],
        ):
            tutor_config.update_with_base(config)
            tutor_config.update_with_defaults(config)
        tutor_config.render_full(config)
        value1 = get_typed(config, "PLUGIN1_PARAM1", str)

        self.assertEqual(10, len(value1))
Ejemplo n.º 5
0
    def test_config_load_from_plugins(self) -> None:
        config: Config = {}

        plugins_v0.DictPlugin({
            "name": "plugin1",
            "config": {
                "add": {
                    "PARAM1": "{{ 10|random_string }}"
                }
            }
        })
        plugins.load("plugin1")

        tutor_config.update_with_base(config)
        tutor_config.update_with_defaults(config)
        tutor_config.render_full(config)
        value1 = get_typed(config, "PLUGIN1_PARAM1", str)

        self.assertEqual(10, len(value1))