def test_invalid_args(self, tmp_path): write_file( tmp_path, textwrap.dedent( """ NAME='foo' VERSION='1.0' PLUGIN_ENTRY='entry.py' PLUGIN_ARGS="invalid" """ ), ) with pytest.raises(PluginValidationError): ConfigLoader.load(tmp_path / CONFIG_NAME)
def test_required_attributes(self, tmp_path, config_all): write_file( tmp_path, textwrap.dedent( """ NAME='foo' VERSION='1.0' PLUGIN_ENTRY='entry.py' """ ), ) assert ConfigLoader.load(tmp_path / CONFIG_NAME) == config_all
def test_explicit_max_instances(self, tmp_path): write_file( tmp_path, textwrap.dedent( """ NAME='foo' VERSION='1.0' PLUGIN_ENTRY='entry.py' INSTANCES=["foo", "bar"] MAX_INSTANCES=-1 """ ), ) loaded_config = ConfigLoader.load(tmp_path / CONFIG_NAME) assert sorted(loaded_config["INSTANCES"]) == sorted(["foo", "bar"]) assert loaded_config["MAX_INSTANCES"] == -1
def test_instance_and_args_list(self, tmp_path): write_file( tmp_path, textwrap.dedent( """ NAME='foo' VERSION='1.0' PLUGIN_ENTRY='entry.py' INSTANCES=["foo", "bar"] PLUGIN_ARGS=["arg1"] """ ), ) loaded_config = ConfigLoader.load(tmp_path / CONFIG_NAME) assert sorted(loaded_config["INSTANCES"]) == sorted(["foo", "bar"]) assert loaded_config["PLUGIN_ARGS"] == {"foo": ["arg1"], "bar": ["arg1"]} assert loaded_config["MAX_INSTANCES"] == -1
def test_plugin_args_list_no_instances(self, tmp_path): write_file( tmp_path, textwrap.dedent( """ NAME='foo' VERSION='1.0' PLUGIN_ENTRY='entry.py' INSTANCES=None PLUGIN_ARGS=["arg1"] """ ), ) loaded_config = ConfigLoader.load(tmp_path / CONFIG_NAME) assert loaded_config["INSTANCES"] == ["default"] assert loaded_config["PLUGIN_ARGS"] == {"default": ["arg1"]} assert loaded_config["MAX_INSTANCES"] == -1
def test_instances_no_plugin_args(self, tmp_path): write_file( tmp_path, textwrap.dedent( """ NAME='foo' VERSION='1.0' PLUGIN_ENTRY='entry.py' INSTANCES=["instance1", "instance2"] PLUGIN_ARGS=None """ ), ) loaded_config = ConfigLoader.load(tmp_path / CONFIG_NAME) assert loaded_config["INSTANCES"] == ["instance1", "instance2"] assert loaded_config["PLUGIN_ARGS"] == {"instance1": None, "instance2": None} assert loaded_config["MAX_INSTANCES"] == -1
def test_all_attributes(self, tmp_path, config_all, config_all_serialized): write_file(tmp_path, config_all_serialized) assert ConfigLoader.load(tmp_path / CONFIG_NAME) == config_all