50 def __debug(self): |
50 def __debug(self): |
51 return xServer('http://localhost:7080/debug') |
51 return xServer('http://localhost:7080/debug') |
52 |
52 |
53 def __rpc2(self): |
53 def __rpc2(self): |
54 return ServerProxy('http://localhost:7080/RPC2') |
54 return ServerProxy('http://localhost:7080/RPC2') |
55 |
55 |
56 def testDebugHello(self): |
56 def testDebugHello(self): |
57 '''simple test for the connection to xmlrpc server''' |
57 '''simple test for the connection to xmlrpc server''' |
58 ret=self.__debug().hello() |
58 ret=self.__debug().hello() |
59 self.failUnlessEqual(ret,'hello') |
59 self.failUnlessEqual(ret,'hello') |
60 |
60 |
64 self.failUnlessEqual(ret, ['listMethods', 'status', 'stop', 'sms', 'fax', 'mail', 'routes', 'defaultRoute', 'statistic']) |
64 self.failUnlessEqual(ret, ['listMethods', 'status', 'stop', 'sms', 'fax', 'mail', 'routes', 'defaultRoute', 'statistic']) |
65 |
65 |
66 def testStatus(self): |
66 def testStatus(self): |
67 ret = self.__rpc2().status('abcdef123456789') |
67 ret = self.__rpc2().status('abcdef123456789') |
68 self.failUnlessEqual(ret, "<User('test','abcdef123456789')>") |
68 self.failUnlessEqual(ret, "<User('test','abcdef123456789')>") |
|
69 self.failUnlessEqual(self.__rpc2().status('abcdef123456789','abcde'), ["<User('test','abcdef123456789')>",'abcde',False]) |
|
70 self.failUnlessEqual(self.__rpc2().status('abcdef123456789','abcde', True), ["<User('test','abcdef123456789')>",'abcde', True]) |
|
71 self.failUnlessEqual(self.__rpc2().status('abcdef123456789', '', 'true'), ["<User('test','abcdef123456789')>", '', True]) |
|
72 self.failUnlessEqual(self.__rpc2().status('abcdef123456789', '', 'false'), "<User('test','abcdef123456789')>") |
|
73 self.failUnlessEqual(self.__rpc2().status('abcdef123456789', '', 0), "<User('test','abcdef123456789')>") |
|
74 self.failUnlessEqual(self.__rpc2().status('abcdef123456789', '', 1), ["<User('test','abcdef123456789')>", '', True]) |
|
75 |
69 |
76 |
70 def testNoSuchUser(self): |
77 def testNoSuchUser(self): |
71 '''a unknown user should raise a UserNotNound Exception |
78 '''a unknown user should raise a UserNotNound Exception |
72 bewcause xmlrpc only has a Fault exception this Exception has to be deliverd through a xmlrpclib.Fault Exception''' |
79 bewcause xmlrpc only has a Fault exception this Exception has to be deliverd through a xmlrpclib.Fault Exception''' |
73 with self.assertRaises(Fault) as fault: |
80 with self.assertRaises(Fault) as fault: |
83 self.__rpc2().nosuchmethod() |
90 self.__rpc2().nosuchmethod() |
84 exc = fault.exception |
91 exc = fault.exception |
85 self.failUnlessEqual(exc.faultCode, 8001) |
92 self.failUnlessEqual(exc.faultCode, 8001) |
86 self.failUnlessEqual(exc.faultString, "procedure nosuchmethod not found") |
93 self.failUnlessEqual(exc.faultString, "procedure nosuchmethod not found") |
87 |
94 |
88 def testValidation(self): |
95 def testValidationFault(self): |
89 '''a validate Exception should be translated to a xmlrpclib.Fault.''' |
96 '''a validate Exception should be translated to a xmlrpclib.Fault.''' |
90 with self.assertRaises(Fault) as fault: |
97 with self.assertRaises(Fault) as fault: |
91 self.__rpc2().status('xxx') |
98 self.__rpc2().status('xxx') |
92 exc = fault.exception |
99 exc = fault.exception |
93 self.failUnlessEqual(exc.faultCode, 700) |
100 self.failUnlessEqual(exc.faultCode, 700) |
94 self.failUnlessEqual(exc.faultString, "Validation of 'apikey' failed.") |
101 self.failUnlessEqual(exc.faultString, "Validation of 'apikey' failed.") |
95 |
|
96 |
|
97 |
102 |
98 def startReactor(engine): |
103 def startReactor(engine): |
99 """starts the Rector with a special debug Clild, so that the reactor can be stopped remotly. """ |
104 """starts the Rector with a special debug Clild, so that the reactor can be stopped remotly. """ |
100 from twisted.internet import reactor |
105 from twisted.internet import reactor |
101 from twisted.web import xmlrpc, resource |
106 from twisted.web import xmlrpc, resource |