2
0

test_rename.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import logging
  2. from flexmock import flexmock
  3. from borgmatic.borg import rename as module
  4. def test_rename_archive_calls_borg_rename():
  5. environment = flexmock()
  6. # Note: make_rename_command is tested as integration test.
  7. flexmock(module).should_receive('make_rename_command').and_return(('borg', 'fake-command'))
  8. flexmock(module.borgmatic.borg.environment).should_receive('make_environment').and_return(
  9. environment,
  10. )
  11. flexmock(module.borgmatic.config.paths).should_receive('get_working_directory').and_return(
  12. '/working/dir',
  13. )
  14. flexmock(module.borgmatic.execute).should_receive('execute_command').with_args(
  15. ('borg', 'fake-command'),
  16. output_log_level=logging.INFO,
  17. environment=environment,
  18. working_directory='/working/dir',
  19. borg_local_path='borg',
  20. borg_exit_codes=None,
  21. ).once()
  22. module.rename_archive(
  23. dry_run=False,
  24. repository_name='repo',
  25. old_archive_name='old_archive',
  26. new_archive_name='new_archive',
  27. config={},
  28. local_borg_version='1.2.3',
  29. local_path='borg',
  30. remote_path=None,
  31. )