A wrapper script for Borg backup software that creates and prunes backups
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_environment.py 1.3KB

  1. import os
  2. from borgmatic.borg import environment as module
  3. def test_initialize_with_passcommand_should_set_environment():
  4. orig_environ = os.environ
  5. try:
  6. os.environ = {}
  7. module.initialize({'encryption_passcommand': 'command'})
  8. assert os.environ.get('BORG_PASSCOMMAND') == 'command'
  9. finally:
  10. os.environ = orig_environ
  11. def test_initialize_with_passphrase_should_set_environment():
  12. orig_environ = os.environ
  13. try:
  14. os.environ = {}
  15. module.initialize({'encryption_passphrase': 'pass'})
  16. assert os.environ.get('BORG_PASSPHRASE') == 'pass'
  17. finally:
  18. os.environ = orig_environ
  19. def test_initialize_with_ssh_command_should_set_environment():
  20. orig_environ = os.environ
  21. try:
  22. os.environ = {}
  23. module.initialize({'ssh_command': 'ssh -C'})
  24. assert os.environ.get('BORG_RSH') == 'ssh -C'
  25. finally:
  26. os.environ = orig_environ
  27. def test_initialize_without_configuration_should_not_set_environment():
  28. orig_environ = os.environ
  29. try:
  30. os.environ = {}
  31. module.initialize({})
  32. assert os.environ.get('BORG_PASSCOMMAND') is None
  33. assert os.environ.get('BORG_PASSPHRASE') is None
  34. assert os.environ.get('BORG_RSH') is None
  35. finally:
  36. os.environ = orig_environ