test_validate.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import argparse
  2. from flexmock import flexmock
  3. import borgmatic.logger
  4. from borgmatic.actions.config import validate as module
  5. def test_run_validate_with_show_renders_configurations():
  6. log_lines = []
  7. borgmatic.logger.add_custom_log_levels()
  8. def fake_logger_answer(message):
  9. log_lines.append(message)
  10. flexmock(module.logger).should_receive('answer').replace_with(fake_logger_answer)
  11. module.run_validate(argparse.Namespace(show=True), {'test.yaml': {'foo': {'bar': 'baz'}}})
  12. assert log_lines == ['''foo:\n bar: baz\n''']
  13. def test_run_validate_with_show_and_multiple_configs_renders_each():
  14. log_lines = []
  15. borgmatic.logger.add_custom_log_levels()
  16. def fake_logger_answer(message):
  17. log_lines.append(message)
  18. flexmock(module.logger).should_receive('answer').replace_with(fake_logger_answer)
  19. module.run_validate(
  20. argparse.Namespace(show=True),
  21. {'test.yaml': {'foo': {'bar': 'baz'}}, 'other.yaml': {'quux': 'value'}},
  22. )
  23. assert log_lines == ['---', 'foo:\n bar: baz\n', '---', 'quux: value\n']