def load_builtin_config(config): stdout_builder = TransformerBuilder() errors = [] ConfigLoader(stdout_builder=stdout_builder, stderr_builder=DummyTransformerBuilder(), paths=['rainbow/config/builtin'], error_handler=errors.append) \ .load_config_by_name(config, ) return stdout_builder.build(), errors
def load_from_command_line(args): stdout_builder = TransformerBuilder() stderr_builder = TransformerBuilder() errors = [] ConfigLoader(stdout_builder=stdout_builder, stderr_builder=stderr_builder, paths=['tests/data/cfg'], error_handler=errors.append) \ .load_config_from_command_line(args) return stdout_builder.build(), stderr_builder.build(), errors
def load_by_name(config): stdout_builder = TransformerBuilder() stderr_builder = TransformerBuilder() errors = [] ConfigLoader(stdout_builder=stdout_builder, stderr_builder=stderr_builder, paths=['tests/data/cfg'], error_handler=errors.append) \ .load_config_by_name(config) return stdout_builder.build(), stderr_builder.build(), errors
def test_find_config_name_from_command_line_precommand(precommand): assert ConfigLoader.find_config_name_from_command_line([precommand, 'foo']) == 'foo'
def test_find_config_name_from_command_line_full_path(): assert ConfigLoader.find_config_name_from_command_line(['/usr/bin/foo' ]) == 'foo'
def test_find_config_name_from_command_line_several_args(): assert ConfigLoader.find_config_name_from_command_line( ['foo', 'bar', 'bar']) == 'foo'
def test_find_config_name_from_command_line_one_arg(): assert ConfigLoader.find_config_name_from_command_line(['foo']) == 'foo'
def test_find_config_name_from_command_line_empty_args(): assert not ConfigLoader.find_config_name_from_command_line([])
def test_find_config_name_from_command_line_full_path_precommand_with_args( precommand): assert ConfigLoader.find_config_name_from_command_line( [precommand, '--arg', '/usr/bin/foo']) == 'foo'