Merge branch 'master' of ssh://git.planet-lab.org/git/sfa
[sfa.git] / sfa / server / modpythonapi / test.py
1 import sys
2 import traceback
3
4 from BaseClient import BaseClient, EnableVerboseExceptions
5 from AuthenticatedClient import AuthenticatedClient
6
7 EnableVerboseExceptions(True)
8
9 HOST = "localhost"
10 URL = "http://" + HOST + "/TESTAPI/"
11 SURL = "https://" + HOST + "/TESTAPI/"
12
13 print "*** testing some valid ops; these should print \"Hello, World\" ***"
14
15 bc = BaseClient(URL)
16 print "HTTP noop:", bc.noop("Hello, World")
17
18 ac = AuthenticatedClient(URL, "gackstestuser.pkey", "gackstestuser.gid")
19 print "HTTP gidNoop:", ac.gidNoop("Hello, World")
20
21 bc = BaseClient(SURL)
22 print "HTTPS noop:", bc.noop("Hello, World")
23
24 ac = AuthenticatedClient(URL, "gackstestuser.pkey", "gackstestuser.gid")
25 print "HTTPS gidNoop:", ac.gidNoop("Hello, World")
26
27 print
28 print "*** testing some exception handling: ***"
29
30 bc = BaseClient(URL)
31 print "HTTP typeError:",
32 try:
33     result = bc.server.typeError()
34     print result
35 except Exception, e:
36     print ''.join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
37
38 print "HTTP badrequesthash:",
39 try:
40     result = bc.server.badRequestHash()
41     print result
42 except:
43     print ''.join(traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
44