-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
executable file
·42 lines (31 loc) · 1.34 KB
/
test.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
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
import os
import base64
from keystore import save, load, config_reader
def test_keystore():
compare_dir = './test/compare'
print('Testing keystore saving...')
save.save(keystorerc='.keystorerc', verbose=True)
if not os.path.exists(compare_dir):
os.makedirs(compare_dir)
print('Testing keystore loading...')
load.load(keystore='testkeystore', copyto='./test/compare', verbose=True)
print('Comparing before and after...')
cf = config_reader.read('.keystorerc')
for f in cf['files']:
if os.path.isdir(f):
for dirpath, dirnames, filenames in os.walk(os.path.expanduser(f)):
original_dir = dirpath
for filename in filenames:
original_path = os.path.join(original_dir, os.path.basename(filename))
copied_path = os.path.join('./test/compare', os.path.basename(filename))
with open(original_path, 'rb') as original, open(copied_path, 'rb') as copy:
assert(original.read() == copy.read())
elif os.path.isfile(f):
original_path = os.path.join(original_dir, os.path.basename(f))
copied_path = os.path.join('./test/compare', os.path.basename(f))
with open(original_path, 'rb') as original, open(copied_path, 'rb') as copy:
assert(original.read() == copy.read())
print('Test successful.')
if __name__ == '__main__':
test_keystore()