| skipped 27 lines |
28 | 28 | | |
29 | 29 | | import os |
30 | 30 | | import unittest |
| 31 | + | from unittest.mock import patch |
31 | 32 | | |
32 | 33 | | from cupp import * |
33 | 34 | | |
| skipped 69 lines |
103 | 104 | | download_wordlist() |
104 | 105 | | filename = "dictionaries/russian/russian.lst.gz" |
105 | 106 | | self.assertTrue(os.path.isfile(filename), "file " + filename + "exists") |
| 107 | + | |
| 108 | + | def test_interactive(self): |
| 109 | + | """ Tests the interactive menu """ |
| 110 | + | |
| 111 | + | expected_filename = "julian.txt" |
| 112 | + | string_to_test = "Julian30771" |
| 113 | + | |
| 114 | + | user_input = [ |
| 115 | + | "Julian", # First Name |
| 116 | + | "Assange", # Surname |
| 117 | + | "Mendax", # Nickname |
| 118 | + | "03071971", # Birthdate |
| 119 | + | "", # Partner |
| 120 | + | "", # Partner nick |
| 121 | + | "", # Partner birthdate |
| 122 | + | "", # Child name |
| 123 | + | "", # Child nick |
| 124 | + | "", # Child birthdate |
| 125 | + | "", # Pet's name |
| 126 | + | "", # Company name |
| 127 | + | "N", # keywords |
| 128 | + | "Y", # Special chars |
| 129 | + | "N", # Random |
| 130 | + | "N", # Leet mode |
| 131 | + | ] |
| 132 | + | |
| 133 | + | test_ok = False |
| 134 | + | |
| 135 | + | if os.path.isfile(expected_filename): |
| 136 | + | if string_to_test in open(expected_filename).read(): |
| 137 | + | test_ok = True |
| 138 | + | |
| 139 | + | with patch("builtins.input", side_effect=user_input): |
| 140 | + | stacks = interactive() |
| 141 | + | |
| 142 | + | self.assertTrue(test_ok, "interactive generation works") |
106 | 143 | | |
107 | 144 | | |
108 | 145 | | if __name__ == "__main__": |
| skipped 2 lines |