test_environment.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. from borgmatic.borg import environment as module
  2. def test_make_environment_with_passcommand_should_set_environment():
  3. environment = module.make_environment({'encryption_passcommand': 'command'})
  4. assert environment.get('BORG_PASSCOMMAND') == 'command'
  5. def test_make_environment_with_passphrase_should_set_environment():
  6. environment = module.make_environment({'encryption_passphrase': 'pass'})
  7. assert environment.get('BORG_PASSPHRASE') == 'pass'
  8. def test_make_environment_with_ssh_command_should_set_environment():
  9. environment = module.make_environment({'ssh_command': 'ssh -C'})
  10. assert environment.get('BORG_RSH') == 'ssh -C'
  11. def test_make_environment_without_configuration_should_only_set_default_environment():
  12. environment = module.make_environment({})
  13. assert environment == {
  14. 'BORG_RELOCATED_REPO_ACCESS_IS_OK': 'no',
  15. 'BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK': 'no',
  16. }
  17. def test_make_environment_with_relocated_repo_access_should_override_default():
  18. environment = module.make_environment({'relocated_repo_access_is_ok': True})
  19. assert environment.get('BORG_RELOCATED_REPO_ACCESS_IS_OK') == 'yes'