test_delete.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from flexmock import flexmock
  2. from borgmatic.actions import delete as module
  3. def test_run_delete_does_not_raise():
  4. flexmock(module.logger).answer = lambda message: None
  5. flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
  6. flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name')
  7. flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
  8. flexmock()
  9. )
  10. flexmock(module.borgmatic.borg.delete).should_receive('delete_archives')
  11. module.run_delete(
  12. repository={'path': 'repo'},
  13. config={},
  14. local_borg_version=None,
  15. delete_arguments=flexmock(repository=flexmock(), archive=flexmock()),
  16. global_arguments=flexmock(),
  17. local_path=None,
  18. remote_path=None,
  19. )
  20. def test_run_delete_without_archive_does_not_raise():
  21. flexmock(module.logger).answer = lambda message: None
  22. flexmock(module.borgmatic.config.validate).should_receive('repositories_match').and_return(True)
  23. flexmock(module.borgmatic.borg.rlist).should_receive('resolve_archive_name')
  24. flexmock(module.borgmatic.actions.arguments).should_receive('update_arguments').and_return(
  25. flexmock()
  26. )
  27. flexmock(module.borgmatic.borg.delete).should_receive('delete_archives')
  28. module.run_delete(
  29. repository={'path': 'repo'},
  30. config={},
  31. local_borg_version=None,
  32. delete_arguments=flexmock(repository=flexmock(), archive=None),
  33. global_arguments=flexmock(),
  34. local_path=None,
  35. remote_path=None,
  36. )