Exemplo 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)
Exemplo n.º 2
0
    def test_configure_set_does_not_override(self) -> None:
        config: Config = {"ID1": "oldid"}

        class plugin1:
            config: Config = {"set": {"ID1": "newid", "ID2": "id2"}}

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

        self.assertEqual("oldid", config["ID1"])
        self.assertEqual("id2", config["ID2"])
Exemplo n.º 3
0
    def test_configure_set_does_not_override(self) -> None:
        config: Config = {"ID1": "oldid"}

        plugins_v0.DictPlugin({
            "name": "plugin1",
            "config": {
                "set": {
                    "ID1": "newid",
                    "ID2": "id2"
                }
            }
        })
        plugins.load("plugin1")
        tutor_config.update_with_base(config)

        self.assertEqual("oldid", config["ID1"])
        self.assertEqual("id2", config["ID2"])
Exemplo 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))
Exemplo 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))