test_normalize.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. {'consistency': {'checks': ['archives']}},
  37. {'consistency': {'checks': [{'name': 'archives'}]}},
  38. ),
  39. ),
  40. )
  41. def test_normalize_applies_hard_coded_normalization_to_config(config, expected_config):
  42. module.normalize(config)
  43. assert config == expected_config