test_execute.py 762 B

12345678910111213141516171819202122232425
  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. subprocess = flexmock(module.subprocess)
  6. subprocess.should_receive('check_call').with_args(full_command).once()
  7. output = module.execute_command(full_command)
  8. assert output is None
  9. def test_execute_command_captures_output():
  10. full_command = ['foo', 'bar']
  11. expected_output = '[]'
  12. subprocess = flexmock(module.subprocess)
  13. 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