2
0

test_schema.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import pkgutil
  2. import borgmatic.actions
  3. import borgmatic.config.load
  4. import borgmatic.config.validate
  5. MAXIMUM_LINE_LENGTH = 80
  6. def test_schema_line_length_stays_under_limit():
  7. schema_file = open('borgmatic/config/schema.yaml')
  8. for line in schema_file.readlines():
  9. assert len(line.rstrip('\n')) <= MAXIMUM_LINE_LENGTH
  10. ACTIONS_MODULE_NAMES_TO_OMIT = {'arguments', 'export_key', 'json'}
  11. ACTIONS_MODULE_NAMES_TO_ADD = {'key', 'umount'}
  12. def test_schema_skip_actions_correspond_to_supported_actions():
  13. '''
  14. Ensure that the allowed actions in the schema's "skip_actions" option don't drift from
  15. borgmatic's actual supported actions.
  16. '''
  17. schema = borgmatic.config.load.load_configuration(borgmatic.config.validate.schema_filename())
  18. schema_skip_actions = set(schema['properties']['skip_actions']['items']['enum'])
  19. supported_actions = {
  20. module.name.replace('_', '-')
  21. for module in pkgutil.iter_modules(borgmatic.actions.__path__)
  22. if module.name not in ACTIONS_MODULE_NAMES_TO_OMIT
  23. }.union(ACTIONS_MODULE_NAMES_TO_ADD)
  24. assert schema_skip_actions == supported_actions