test_schema.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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.validate.schema_filename())
  8. for line in schema_file.readlines():
  9. assert len(line.rstrip('\n')) <= MAXIMUM_LINE_LENGTH
  10. ACTIONS_MODULE_NAMES_TO_OMIT = {
  11. 'arguments',
  12. 'change_passphrase',
  13. 'export_key',
  14. 'import_key',
  15. 'json',
  16. }
  17. ACTIONS_MODULE_NAMES_TO_ADD = {'key', 'umount'}
  18. def test_schema_skip_actions_correspond_to_supported_actions():
  19. '''
  20. Ensure that the allowed actions in the schema's "skip_actions" option don't drift from
  21. borgmatic's actual supported actions.
  22. '''
  23. schema = borgmatic.config.load.load_configuration(borgmatic.config.validate.schema_filename())
  24. schema_skip_actions = set(schema['properties']['skip_actions']['items']['enum'])
  25. supported_actions = {
  26. module.name.replace('_', '-')
  27. for module in pkgutil.iter_modules(borgmatic.actions.__path__)
  28. if module.name not in ACTIONS_MODULE_NAMES_TO_OMIT
  29. }.union(ACTIONS_MODULE_NAMES_TO_ADD)
  30. assert schema_skip_actions == supported_actions