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.
 
 
 
 
 
 

41 lines
1.2 KiB

  1. import unittest
  2. import pexpect
  3. import argparse
  4. from lesspass.cli import range_type
  5. class TestFunctional(unittest.TestCase):
  6. def test_length_below_the_minimum(self):
  7. p = pexpect.spawn(
  8. "python3 lesspass/core.py site login masterpassword --lowercase --digits --length 2"
  9. )
  10. output = p.read().decode()
  11. self.assertTrue(
  12. "error: argument -L/--length: 2 is out of range, choose in [5-35]" in output
  13. )
  14. def test_length_range_type(self):
  15. self.assertEqual(range_type("5"), 5)
  16. self.assertEqual(range_type("35"), 35)
  17. with self.assertRaises(argparse.ArgumentTypeError):
  18. range_type("2")
  19. def test_exclude(self):
  20. p = pexpect.spawn(
  21. 'python3 lesspass/core.py site login masterpassword --exclude "!@$*+-8"'
  22. )
  23. output = p.read().decode()
  24. for c in "!@$*+-8":
  25. self.assertTrue(c not in output)
  26. def test_exclude(self):
  27. p = pexpect.spawn(
  28. 'python3 lesspass/core.py site login masterpassword -d -L6 --exclude "0123456789"'
  29. )
  30. output = p.read().decode()
  31. self.assertTrue("error: you can't exclude all chars available" in output)