Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

test_profile.py 6.4 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import unittest
  2. from lesspass.cli import parse_args
  3. from lesspass.profile import create_profile
  4. class TestProfile(unittest.TestCase):
  5. def test_create_profile_default(self):
  6. profile = create_profile(parse_args(["site", "login"]))
  7. self.assertTrue(profile["lowercase"])
  8. self.assertTrue(profile["uppercase"])
  9. self.assertTrue(profile["digits"])
  10. self.assertTrue(profile["symbols"])
  11. self.assertEqual(profile["length"], 16)
  12. self.assertEqual(profile["counter"], 1)
  13. self.assertEqual(profile["site"], "site")
  14. self.assertEqual(profile["login"], "login")
  15. self.assertEqual(profile["exclude"], "")
  16. def test_create_profile_login(self):
  17. profile = create_profile(parse_args(["site"]))
  18. self.assertEqual(profile["login"], "")
  19. def test_create_profile_length(self):
  20. profile = create_profile(parse_args(["site", "--length", "8"]))
  21. self.assertEqual(profile["length"], 8)
  22. def test_create_profile_counter(self):
  23. profile = create_profile(parse_args(["site", "--counter", "2"]))
  24. self.assertEqual(profile["counter"], 2)
  25. def test_create_profile_l(self):
  26. profile = create_profile(parse_args(["site", "-l"]))
  27. self.assertTrue(profile["lowercase"])
  28. self.assertFalse(profile["uppercase"])
  29. self.assertFalse(profile["digits"])
  30. self.assertFalse(profile["symbols"])
  31. def test_create_profile_u(self):
  32. profile = create_profile(parse_args(["site", "-u"]))
  33. self.assertFalse(profile["lowercase"])
  34. self.assertTrue(profile["uppercase"])
  35. self.assertFalse(profile["digits"])
  36. self.assertFalse(profile["symbols"])
  37. def test_create_profile_d(self):
  38. profile = create_profile(parse_args(["site", "-d"]))
  39. self.assertFalse(profile["lowercase"])
  40. self.assertFalse(profile["uppercase"])
  41. self.assertTrue(profile["digits"])
  42. self.assertFalse(profile["symbols"])
  43. def test_create_profile_s(self):
  44. profile = create_profile(parse_args(["site", "-s"]))
  45. self.assertFalse(profile["lowercase"])
  46. self.assertFalse(profile["uppercase"])
  47. self.assertFalse(profile["digits"])
  48. self.assertTrue(profile["symbols"])
  49. def test_create_profile_lu(self):
  50. profile = create_profile(parse_args(["site", "-lu"]))
  51. self.assertTrue(profile["lowercase"])
  52. self.assertTrue(profile["uppercase"])
  53. self.assertFalse(profile["digits"])
  54. self.assertFalse(profile["symbols"])
  55. def test_create_profile_ld(self):
  56. profile = create_profile(parse_args(["site", "-ld"]))
  57. self.assertTrue(profile["lowercase"])
  58. self.assertFalse(profile["uppercase"])
  59. self.assertTrue(profile["digits"])
  60. self.assertFalse(profile["symbols"])
  61. def test_create_profile_ls(self):
  62. profile = create_profile(parse_args(["site", "-ls"]))
  63. self.assertTrue(profile["lowercase"])
  64. self.assertFalse(profile["uppercase"])
  65. self.assertFalse(profile["digits"])
  66. self.assertTrue(profile["symbols"])
  67. def test_create_profile_ud(self):
  68. profile = create_profile(parse_args(["site", "-ud"]))
  69. self.assertFalse(profile["lowercase"])
  70. self.assertTrue(profile["uppercase"])
  71. self.assertTrue(profile["digits"])
  72. self.assertFalse(profile["symbols"])
  73. def test_create_profile_us(self):
  74. profile = create_profile(parse_args(["site", "-us"]))
  75. self.assertFalse(profile["lowercase"])
  76. self.assertTrue(profile["uppercase"])
  77. self.assertFalse(profile["digits"])
  78. self.assertTrue(profile["symbols"])
  79. def test_create_profile_ds(self):
  80. profile = create_profile(parse_args(["site", "-ds"]))
  81. self.assertFalse(profile["lowercase"])
  82. self.assertFalse(profile["uppercase"])
  83. self.assertTrue(profile["digits"])
  84. self.assertTrue(profile["symbols"])
  85. def test_create_profile_lud(self):
  86. profile = create_profile(parse_args(["site", "-lud"]))
  87. self.assertTrue(profile["lowercase"])
  88. self.assertTrue(profile["uppercase"])
  89. self.assertTrue(profile["digits"])
  90. self.assertFalse(profile["symbols"])
  91. def test_create_profile_lus(self):
  92. profile = create_profile(parse_args(["site", "-lus"]))
  93. self.assertTrue(profile["lowercase"])
  94. self.assertTrue(profile["uppercase"])
  95. self.assertFalse(profile["digits"])
  96. self.assertTrue(profile["symbols"])
  97. def test_create_profile_uds(self):
  98. profile = create_profile(parse_args(["site", "-uds"]))
  99. self.assertFalse(profile["lowercase"])
  100. self.assertTrue(profile["uppercase"])
  101. self.assertTrue(profile["digits"])
  102. self.assertTrue(profile["symbols"])
  103. def test_create_profile_luds(self):
  104. profile = create_profile(parse_args(["site", "-luds"]))
  105. self.assertTrue(profile["lowercase"])
  106. self.assertTrue(profile["uppercase"])
  107. self.assertTrue(profile["digits"])
  108. self.assertTrue(profile["symbols"])
  109. def test_create_profile_suld(self):
  110. profile = create_profile(parse_args(["site", "-suld"]))
  111. self.assertTrue(profile["lowercase"])
  112. self.assertTrue(profile["uppercase"])
  113. self.assertTrue(profile["digits"])
  114. self.assertTrue(profile["symbols"])
  115. def test_create_profile_nl(self):
  116. profile = create_profile(parse_args(["site", "--no-lowercase"]))
  117. self.assertFalse(profile["lowercase"])
  118. self.assertTrue(profile["uppercase"])
  119. self.assertTrue(profile["digits"])
  120. self.assertTrue(profile["symbols"])
  121. def test_create_profile_nu(self):
  122. profile = create_profile(parse_args(["site", "--no-uppercase"]))
  123. self.assertTrue(profile["lowercase"])
  124. self.assertFalse(profile["uppercase"])
  125. self.assertTrue(profile["digits"])
  126. self.assertTrue(profile["symbols"])
  127. def test_create_profile_nd(self):
  128. profile = create_profile(parse_args(["site", "--no-digits"]))
  129. self.assertTrue(profile["lowercase"])
  130. self.assertTrue(profile["uppercase"])
  131. self.assertFalse(profile["digits"])
  132. self.assertTrue(profile["symbols"])
  133. def test_create_profile_ns(self):
  134. profile = create_profile(parse_args(["site", "--no-symbols"]))
  135. self.assertTrue(profile["lowercase"])
  136. self.assertTrue(profile["uppercase"])
  137. self.assertTrue(profile["digits"])
  138. self.assertFalse(profile["symbols"])