test_execute.py 747 B

1234567891011121314151617181920212223242526
  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(
  6. full_command, output_as_warning=False
  7. ).once()
  8. output = module.execute_command(full_command)
  9. assert output is None
  10. def test_execute_command_captures_output():
  11. full_command = ['foo', 'bar']
  12. expected_output = '[]'
  13. flexmock(module.subprocess).should_receive('check_output').with_args(full_command).and_return(
  14. flexmock(decode=lambda: expected_output)
  15. ).once()
  16. output = module.execute_command(full_command, capture_output=True)
  17. assert output == expected_output