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)
#!/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
# easy_install bertrpc import bertrpc service = bertrpc.Service('127.0.0.1', 9999) response = service.request('call').lists.reverse([1, 2, 3]) print(response)
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)
def testValidRequestOptions(self): service = bertrpc.Service('localhost', 9999) options = {'cache': ['validation', 'myToken']} request = service.request('call', options) self.assertEqual(options, request.options)
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)
def testValidRequestInitializationWithTimeout(self): service = bertrpc.Service('localhost', 9999, 12) self.assertEqual('localhost', service.host) self.assertEqual(9999, service.port) self.assertEqual(12, service.timeout)