/
test.py
101 lines (91 loc) · 2.45 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python
import tentog as to
import lib.libconfig
import lib.liblogin as login
import sys
import pprint
def test_getconfig(config):
print "\ntest001"
print "======="
print "description: find config dir"
print "testobject: class config def getconfigpath"
print "input: none"
print "output: path to tentog config directory"
print "result:"
try:
print config.configpath
print "PASS"
except AttributeError, e:
sys.stderr.write(str(e)+"\n")
print "FAIL"
sys.exit(1)
def test_openconfig(config):
print "\ntest002"
print "======="
print "description: try to open config file"
print "testobject: class config def openconfig"
print "input: getconfigpath+/config"
print "output: filehandle"
print "result:"
try:
print config.fhandle
print "PASS"
except Exception, e:
sys.stderr.write(str(e)+"\n")
print "FAIL"
sys.exit(1)
def test_readconfig(config):
print "\ntest003"
print "======="
print "description: try to read required values from config file"
print "testobject: class config def readconfig"
print "input: openconfig"
print "output: string required values: entity, keystore"
print "result:"
try:
print config.keystore
print config.entityUrl
print config.datastore
print "PASS"
except Exception, e:
print e
print "FAIL"
sys.exit(1)
def test_getvalue(config):
print "\ntest004"
print "======="
print "description: get one optional value from config file"
print "testobject: class config def readconfig"
print "input: string"
print "output: value"
print "result:"
try:
print config.editor
print "PASS"
except Exception, e:
print e
def test_login():
print "\ntest005"
print "======="
print "description: login to server"
print "testobject: def login"
print "input: "
print "output: profile"
print "result:"
print pprint.pformat(login.login(test=1))
def starttests():
#config test scope : config
config=lib.libconfig.config()
#test001
test_getconfig(config)
#test002
test_openconfig(config)
#test003
test_readconfig(config)
#test004
test_getvalue(config)
#config test scope : login
#test005
test_login()
if __name__=="__main__":
starttests()