forked from MatthewWest/pass-alfred
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_pass.py
31 lines (23 loc) · 1.08 KB
/
test_pass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pass_module = __import__('pass')
import unittest, shutil, os
class TestPassHelperFunctions(unittest.TestCase):
def make_test_file(self, new_file_path):
dirname = os.path.dirname(new_file_path)
if not os.path.exists(dirname):
os.makedirs(dirname)
if not os.path.exists(new_file_path):
open(new_file_path, 'a').close()
def setUp(self):
test_files = ['testing/top1', 'testing/top2', 'testing/mid/mid', 'testing/mid/bottom/bottom']
current_dir = os.path.dirname(os.path.realpath(__file__))
self.top_directory = os.path.join(current_dir, 'testing')
self.test_file_dirs = sorted([os.path.join(current_dir, test_file) for test_file in test_files])
for filename in self.test_file_dirs:
self.make_test_file(filename)
def test_extract_pw_keys(self):
results = sorted(pass_module.extract_pw_keys(self.top_directory))
self.assertEqual(self.test_file_dirs, results)
def tearDown(self):
shutil.rmtree(self.top_directory)
if __name__ == '__main__':
unittest.main()