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.

test_functional.py 1.2 KiB

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