Esempio 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)
Esempio n. 2
0
 def test_configure_default_value_with_previous_definition(self) -> None:
     config: Config = {"PARAM1": "value"}
     plugins_v0.DictPlugin({
         "name": "plugin1",
         "config": {
             "defaults": {
                 "PARAM2": "{{ PARAM1 }}"
             }
         }
     })
     plugins.load("plugin1")
     tutor_config.update_with_defaults(config)
     self.assertEqual("{{ PARAM1 }}", config["PLUGIN1_PARAM2"])
Esempio n. 3
0
    def test_configure_default_value_with_previous_definition(self) -> None:
        config: Config = {"PARAM1": "value"}

        class plugin1:
            config: Config = {"defaults": {"PARAM2": "{{ PARAM1 }}"}}

        with patch.object(
                plugins.Plugins,
                "iter_enabled",
                return_value=[plugins.BasePlugin("plugin1", plugin1)],
        ):
            tutor_config.update_with_defaults(config)
        self.assertEqual("{{ PARAM1 }}", config["PLUGIN1_PARAM2"])
Esempio 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))
Esempio 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))