-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtests.py
65 lines (47 loc) · 1.21 KB
/
tests.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import sys
import settings
import auth
import actions
from colorama import init
init()
from colorama import Fore, Style
failed = []
passed = []
# Colorized output plus counters
def p_ok(text):
passed.append(text)
print(Fore.GREEN + text + Style.RESET_ALL)
def p_fail(text):
failed.append(text)
print(Fore.RED + text + Style.RESET_ALL)
def wwn(text):
sys.stdout.write(text)
sys.stdout.flush()
def login():
wwn('Testing login.. ')
try:
r = auth.log_in(settings.servers['master'])
if not r.verify:
p_fail('Login test failed!')
else:
p_ok('Login succeeded')
except:
p_fail('Login test failed!')
def get_users():
wwn('Testing GET users list.. ')
try:
r = actions.get_users(settings.servers['master'])
if not r.ok:
p_fail('GET users failed!')
else:
p_ok('GET users list succeeded')
except:
p_fail('GET users failed!')
# Run all tests
def run_tests():
login()
get_users()
print(Fore.GREEN + "Passed: " + str(len(passed)) + Style.RESET_ALL )
print(Fore.RED + "Failed: " + str(len(failed)) + Style.RESET_ALL )
if __name__ == "__main__":
run_tests()