Skip to content

Commit

Permalink
Fix traceback when upgrading old INI-style configuration with upgrade…
Browse files Browse the repository at this point in the history
…-borgmatic-config (#367).
  • Loading branch information
witten committed Nov 18, 2020
1 parent b619bde commit 9b819f3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* #355: Fix traceback when a database hook value is null in a configuration file.
* #361: Merge override values when specifying the "--override" flag multiple times. The previous
behavior was to take the value of the last "--override" flag only.
* #367: Fix traceback when upgrading old INI-style configuration with upgrade-borgmatic-config.
* #368: Fix signal forwarding from borgmatic to Borg resulting in recursion traceback.
* #369: Document support for Borg placeholders in repository names.

Expand Down
4 changes: 3 additions & 1 deletion borgmatic/commands/convert_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def main(): # pragma: no cover
)

generate.write_configuration(
args.destination_config_filename, destination_config, mode=source_config_file_mode
args.destination_config_filename,
generate.render_configuration(destination_config),
mode=source_config_file_mode,
)

display_result(args)
Expand Down
4 changes: 2 additions & 2 deletions borgmatic/config/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _comment_out_optional_configuration(rendered_config):
return '\n'.join(lines)


def _render_configuration(config):
def render_configuration(config):
'''
Given a config data structure of nested OrderedDicts, render the config as YAML and return it.
'''
Expand Down Expand Up @@ -284,5 +284,5 @@ def generate_sample_configuration(source_filename, destination_filename, schema_

write_configuration(
destination_filename,
_comment_out_optional_configuration(_render_configuration(destination_config)),
_comment_out_optional_configuration(render_configuration(destination_config)),
)
8 changes: 4 additions & 4 deletions tests/integration/config/test_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def test_comment_out_optional_configuration_comments_optional_config_only():
assert module._comment_out_optional_configuration(config.strip()) == expected_config.strip()


def test_render_configuration_converts_configuration_to_yaml_string():
yaml_string = module._render_configuration({'foo': 'bar'})
def testrender_configuration_converts_configuration_to_yaml_string():
yaml_string = module.render_configuration({'foo': 'bar'})

assert yaml_string == 'foo: bar\n'

Expand Down Expand Up @@ -194,7 +194,7 @@ def test_generate_sample_configuration_does_not_raise():
flexmock(module.yaml).should_receive('round_trip_load')
flexmock(module).should_receive('_schema_to_sample_configuration')
flexmock(module).should_receive('merge_source_configuration_into_destination')
flexmock(module).should_receive('_render_configuration')
flexmock(module).should_receive('render_configuration')
flexmock(module).should_receive('_comment_out_optional_configuration')
flexmock(module).should_receive('write_configuration')

Expand All @@ -208,7 +208,7 @@ def test_generate_sample_configuration_with_source_filename_does_not_raise():
flexmock(module.load).should_receive('load_configuration')
flexmock(module).should_receive('_schema_to_sample_configuration')
flexmock(module).should_receive('merge_source_configuration_into_destination')
flexmock(module).should_receive('_render_configuration')
flexmock(module).should_receive('render_configuration')
flexmock(module).should_receive('_comment_out_optional_configuration')
flexmock(module).should_receive('write_configuration')

Expand Down

0 comments on commit 9b819f3

Please sign in to comment.