test_normalize.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import pytest
  2. from borgmatic.config import normalize as module
  3. @pytest.mark.parametrize(
  4. 'config,expected_config',
  5. (
  6. (
  7. {'location': {'exclude_if_present': '.nobackup'}},
  8. {'location': {'exclude_if_present': ['.nobackup']}},
  9. ),
  10. (
  11. {'location': {'exclude_if_present': ['.nobackup']}},
  12. {'location': {'exclude_if_present': ['.nobackup']}},
  13. ),
  14. (
  15. {'location': {'source_directories': ['foo', 'bar']}},
  16. {'location': {'source_directories': ['foo', 'bar']}},
  17. ),
  18. ({'storage': {'compression': 'yes_please'}}, {'storage': {'compression': 'yes_please'}}),
  19. (
  20. {'hooks': {'healthchecks': 'https://example.com'}},
  21. {'hooks': {'healthchecks': {'ping_url': 'https://example.com'}}},
  22. ),
  23. (
  24. {'hooks': {'cronitor': 'https://example.com'}},
  25. {'hooks': {'cronitor': {'ping_url': 'https://example.com'}}},
  26. ),
  27. (
  28. {'hooks': {'pagerduty': 'https://example.com'}},
  29. {'hooks': {'pagerduty': {'integration_key': 'https://example.com'}}},
  30. ),
  31. (
  32. {'hooks': {'cronhub': 'https://example.com'}},
  33. {'hooks': {'cronhub': {'ping_url': 'https://example.com'}}},
  34. ),
  35. ),
  36. )
  37. def test_normalize_applies_hard_coded_normalization_to_config(config, expected_config):
  38. module.normalize(config)
  39. assert config == expected_config