test_completions.py 757 B

123456789101112131415161718192021
  1. from argparse import Action
  2. import pytest
  3. from borgmatic.commands.completion import has_exact_options, has_file_options
  4. file_options_test_data = [
  5. (Action('--flag', 'flag'), False),
  6. (Action('--flag', 'flag', metavar='FILENAME'), True),
  7. (Action('--flag', 'flag', metavar='PATH'), True),
  8. (Action('--flag', dest='config_paths'), True),
  9. (Action('--flag', 'flag', metavar='OTHER'), False),
  10. ]
  11. @pytest.mark.parametrize('action, expected', file_options_test_data)
  12. def test_has_file_options_detects_file_options(action: Action, expected: bool):
  13. assert has_file_options(action) == expected
  14. # if has_file_options(action) was true, has_exact_options(action) should also be true
  15. if expected:
  16. assert has_exact_options(action)