test_execute.py 771 B

12345678910111213141516171819202122232425262728
  1. import logging
  2. from flexmock import flexmock
  3. from borgmatic.borg import execute as module
  4. def test_execute_command_calls_full_command():
  5. full_command = ['foo', 'bar']
  6. flexmock(module).should_receive('execute_and_log_output').with_args(
  7. full_command, output_log_level=logging.INFO
  8. ).once()
  9. output = module.execute_command(full_command)
  10. assert output is None
  11. def test_execute_command_captures_output():
  12. full_command = ['foo', 'bar']
  13. expected_output = '[]'
  14. flexmock(module.subprocess).should_receive('check_output').with_args(full_command).and_return(
  15. flexmock(decode=lambda: expected_output)
  16. ).once()
  17. output = module.execute_command(full_command, output_log_level=None)
  18. assert output == expected_output