Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

test_profile.py 6.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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, master_password = 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.assertIsNone(master_password)
  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_master_password(self):
  26. _, master_password = create_profile(
  27. parse_args(["site", "login", "master_password"])
  28. )
  29. self.assertEqual(master_password, "master_password")
  30. def test_create_profile_l(self):
  31. profile, _ = create_profile(parse_args(["site", "-l"]))
  32. self.assertTrue(profile["lowercase"])
  33. self.assertFalse(profile["uppercase"])
  34. self.assertFalse(profile["digits"])
  35. self.assertFalse(profile["symbols"])
  36. def test_create_profile_u(self):
  37. profile, _ = create_profile(parse_args(["site", "-u"]))
  38. self.assertFalse(profile["lowercase"])
  39. self.assertTrue(profile["uppercase"])
  40. self.assertFalse(profile["digits"])
  41. self.assertFalse(profile["symbols"])
  42. def test_create_profile_d(self):
  43. profile, _ = create_profile(parse_args(["site", "-d"]))
  44. self.assertFalse(profile["lowercase"])
  45. self.assertFalse(profile["uppercase"])
  46. self.assertTrue(profile["digits"])
  47. self.assertFalse(profile["symbols"])
  48. def test_create_profile_s(self):
  49. profile, _ = create_profile(parse_args(["site", "-s"]))
  50. self.assertFalse(profile["lowercase"])
  51. self.assertFalse(profile["uppercase"])
  52. self.assertFalse(profile["digits"])
  53. self.assertTrue(profile["symbols"])
  54. def test_create_profile_lu(self):
  55. profile, _ = create_profile(parse_args(["site", "-lu"]))
  56. self.assertTrue(profile["lowercase"])
  57. self.assertTrue(profile["uppercase"])
  58. self.assertFalse(profile["digits"])
  59. self.assertFalse(profile["symbols"])
  60. def test_create_profile_ld(self):
  61. profile, _ = create_profile(parse_args(["site", "-ld"]))
  62. self.assertTrue(profile["lowercase"])
  63. self.assertFalse(profile["uppercase"])
  64. self.assertTrue(profile["digits"])
  65. self.assertFalse(profile["symbols"])
  66. def test_create_profile_ls(self):
  67. profile, _ = create_profile(parse_args(["site", "-ls"]))
  68. self.assertTrue(profile["lowercase"])
  69. self.assertFalse(profile["uppercase"])
  70. self.assertFalse(profile["digits"])
  71. self.assertTrue(profile["symbols"])
  72. def test_create_profile_ud(self):
  73. profile, _ = create_profile(parse_args(["site", "-ud"]))
  74. self.assertFalse(profile["lowercase"])
  75. self.assertTrue(profile["uppercase"])
  76. self.assertTrue(profile["digits"])
  77. self.assertFalse(profile["symbols"])
  78. def test_create_profile_us(self):
  79. profile, _ = create_profile(parse_args(["site", "-us"]))
  80. self.assertFalse(profile["lowercase"])
  81. self.assertTrue(profile["uppercase"])
  82. self.assertFalse(profile["digits"])
  83. self.assertTrue(profile["symbols"])
  84. def test_create_profile_ds(self):
  85. profile, _ = create_profile(parse_args(["site", "-ds"]))
  86. self.assertFalse(profile["lowercase"])
  87. self.assertFalse(profile["uppercase"])
  88. self.assertTrue(profile["digits"])
  89. self.assertTrue(profile["symbols"])
  90. def test_create_profile_lud(self):
  91. profile, _ = create_profile(parse_args(["site", "-lud"]))
  92. self.assertTrue(profile["lowercase"])
  93. self.assertTrue(profile["uppercase"])
  94. self.assertTrue(profile["digits"])
  95. self.assertFalse(profile["symbols"])
  96. def test_create_profile_lus(self):
  97. profile, _ = create_profile(parse_args(["site", "-lus"]))
  98. self.assertTrue(profile["lowercase"])
  99. self.assertTrue(profile["uppercase"])
  100. self.assertFalse(profile["digits"])
  101. self.assertTrue(profile["symbols"])
  102. def test_create_profile_uds(self):
  103. profile, _ = create_profile(parse_args(["site", "-uds"]))
  104. self.assertFalse(profile["lowercase"])
  105. self.assertTrue(profile["uppercase"])
  106. self.assertTrue(profile["digits"])
  107. self.assertTrue(profile["symbols"])
  108. def test_create_profile_luds(self):
  109. profile, _ = create_profile(parse_args(["site", "-luds"]))
  110. self.assertTrue(profile["lowercase"])
  111. self.assertTrue(profile["uppercase"])
  112. self.assertTrue(profile["digits"])
  113. self.assertTrue(profile["symbols"])
  114. def test_create_profile_suld(self):
  115. profile, _ = create_profile(parse_args(["site", "-suld"]))
  116. self.assertTrue(profile["lowercase"])
  117. self.assertTrue(profile["uppercase"])
  118. self.assertTrue(profile["digits"])
  119. self.assertTrue(profile["symbols"])
  120. def test_create_profile_nl(self):
  121. profile, _ = create_profile(parse_args(["site", "--no-lowercase"]))
  122. self.assertFalse(profile["lowercase"])
  123. self.assertTrue(profile["uppercase"])
  124. self.assertTrue(profile["digits"])
  125. self.assertTrue(profile["symbols"])
  126. def test_create_profile_nu(self):
  127. profile, _ = create_profile(parse_args(["site", "--no-uppercase"]))
  128. self.assertTrue(profile["lowercase"])
  129. self.assertFalse(profile["uppercase"])
  130. self.assertTrue(profile["digits"])
  131. self.assertTrue(profile["symbols"])
  132. def test_create_profile_nd(self):
  133. profile, _ = create_profile(parse_args(["site", "--no-digits"]))
  134. self.assertTrue(profile["lowercase"])
  135. self.assertTrue(profile["uppercase"])
  136. self.assertFalse(profile["digits"])
  137. self.assertTrue(profile["symbols"])
  138. def test_create_profile_ns(self):
  139. profile, _ = create_profile(parse_args(["site", "--no-symbols"]))
  140. self.assertTrue(profile["lowercase"])
  141. self.assertTrue(profile["uppercase"])
  142. self.assertTrue(profile["digits"])
  143. self.assertFalse(profile["symbols"])