test_create.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. from flexmock import flexmock
  2. from borgmatic.actions import create as module
  3. def test_run_create_executes_and_calls_hooks():
  4. flexmock(module.logger).answer = lambda message: None
  5. flexmock(module.borgmatic.borg.create).should_receive('create_archive')
  6. flexmock(module.borgmatic.hooks.command).should_receive('execute_hook').times(2)
  7. flexmock(module.borgmatic.hooks.dispatch).should_receive('call_hooks').and_return({})
  8. flexmock(module.borgmatic.hooks.dispatch).should_receive(
  9. 'call_hooks_even_if_unconfigured'
  10. ).and_return({})
  11. create_arguments = flexmock(
  12. progress=flexmock(), stats=flexmock(), json=flexmock(), list_files=flexmock()
  13. )
  14. global_arguments = flexmock(monitoring_verbosity=1, dry_run=False)
  15. list(
  16. module.run_create(
  17. config_filename='test.yaml',
  18. repository='repo',
  19. location={},
  20. storage={},
  21. hooks={},
  22. hook_context={},
  23. local_borg_version=None,
  24. create_arguments=create_arguments,
  25. global_arguments=global_arguments,
  26. dry_run_label='',
  27. local_path=None,
  28. remote_path=None,
  29. )
  30. )