test_execute.py 708 B

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