Example #1
0
 def testInvalidRequestOptions(self):
     service = bertrpc.Service('localhost', 9999)
     options1 = {'fakeOption': 0}
     options2 = {'cache': ['validation', 1234]}
     self.assertRaises(bertrpc.error.InvalidOption, service.request, 'call',
                       options1)
     self.assertRaises(bertrpc.error.InvalidOption, service.request, 'call',
                       options2)
Example #2
0
#!/usr/bin/env python
"""
    Simple client in Python calling example aberth service
"""

import bertrpc
service = bertrpc.Service('localhost', 10001)
response = service.request('call').example.adder(203, 302)
assert response == 505
response = service.request('call').dictoid.to_dict("aberth", "is", "great")
print response
Example #3
0
# easy_install bertrpc

import bertrpc
service = bertrpc.Service('127.0.0.1', 9999)

response = service.request('call').lists.reverse([1, 2, 3])
print(response)
Example #4
0
 def testValidRequestInitializationNoTimeout(self):
     service = bertrpc.Service('localhost', 9999)
     service_with_timeout = bertrpc.Service('localhost', 9999, 12)
     self.assertEqual('localhost', service.host)
     self.assertEqual(9999, service.port)
     self.assertEqual(None, service.timeout)
Example #5
0
 def testValidRequestOptions(self):
     service = bertrpc.Service('localhost', 9999)
     options = {'cache': ['validation', 'myToken']}
     request = service.request('call', options)
     self.assertEqual(options, request.options)
Example #6
0
 def testInvalidRequestKind(self):
     service = bertrpc.Service('localhost', 9999)
     request_kind = 'jump'  # valid options are 'call', 'cast', ...
     self.assertRaises(bertrpc.error.InvalidRequest, service.request,
                       request_kind)
Example #7
0
 def testValidRequestInitializationWithTimeout(self):
     service = bertrpc.Service('localhost', 9999, 12)
     self.assertEqual('localhost', service.host)
     self.assertEqual(9999, service.port)
     self.assertEqual(12, service.timeout)