You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 line
2.2 KiB

  1. import unittest
  2. from lesspass.cli import parse_args
  3. from lesspass.validator import validate_args
  4. class TestValidateArgs(unittest.TestCase):
  5. def test_validate_args_no_opposite_rules_lowercase(self):
  6. error, message = validate_args(parse_args(["site", "-l", "--no-lowercase"]))
  7. self.assertTrue(error)
  8. self.assertTrue(
  9. "Can't have -l (--lowercase) and --no-lowercase at the same time" in message
  10. )
  11. def test_validate_args_no_opposite_rules_uppercase(self):
  12. error, message = validate_args(parse_args(["site", "-u", "--no-uppercase"]))
  13. self.assertTrue(error)
  14. self.assertTrue(
  15. "Can't have -u (--uppercase) and --no-uppercase at the same time" in message
  16. )
  17. def test_validate_args_no_opposite_rules_digits(self):
  18. error, message = validate_args(parse_args(["site", "-d", "--no-digits"]))
  19. self.assertTrue(error)
  20. self.assertTrue(
  21. "Can't have -d (--digits) and --no-digits at the same time" in message
  22. )
  23. def test_validate_args_no_opposite_rules_symbols(self):
  24. error, message = validate_args(parse_args(["site", "-s", "--no-symbols"]))
  25. self.assertTrue(error)
  26. self.assertTrue(
  27. "Can't have -s (--symbols) and --no-symbols at the same time" in message
  28. )
  29. def test_validate_args_concat_errors(self):
  30. _, message = validate_args(
  31. parse_args(["site", "-u", "--no-uppercase", "-l", "--no-lowercase"])
  32. )
  33. self.assertTrue(
  34. "Can't have -l (--lowercase) and --no-lowercase at the same time" in message
  35. )
  36. self.assertTrue(
  37. "Can't have -u (--uppercase) and --no-uppercase at the same time" in message
  38. )
  39. def test_validate_args_no_site(self):
  40. error, message = validate_args(parse_args([]))
  41. self.assertTrue(error)
  42. self.assertTrue(
  43. "SITE is a required argument" in message
  44. )
  45. def test_validate_args_site_optional_with_prompt(self):
  46. error, message = validate_args(parse_args(["--prompt"]))
  47. self.assertFalse(error)
  48. self.assertTrue(
  49. "SITE is a required argument" not in message
  50. )