Beispiel #1
0
 def test_validate_args(self):
   sig = 'jsonrpc(String, String) -> String'
   M = jsonrpc_method(sig, validate=True)(lambda r, s1, s2: s1+s2)
   self.assert_(validate_params(M, {'params': ['omg', u'wtf']}) is None)
   
   E = None
   try:
     validate_params(M, {'params': [['omg'], ['wtf']]})
   except Exception, e:
     E = e
Beispiel #2
0
 def test_validate_args_any(self):
     sig = 'jsonrpc(s1=Any, s2=Any)'
     M = jsonrpc_method(sig, validate=True)(lambda r, s1, s2: s1 + s2)
     self.assert_(validate_params(M, {'params': ['omg', 'wtf']}) is None)
     self.assert_(
         validate_params(M, {'params': [['omg'], ['wtf']]}) is None)
     self.assert_(
         validate_params(M, {'params': {
             's1': 'omg',
             's2': 'wtf'
         }}) is None)
Beispiel #3
0
 def test_validate_args(self):
     sig = 'jsonrpc(String, String) -> String'
     M = jsonrpc_method(sig, validate=True)(lambda r, s1, s2: s1+s2)
     self.assertTrue(validate_params(M, {'params': ['omg', 'wtf']}) is None)
     print(M)
     E = None
     try:
         validate_params(M, {'params': [['omg'], ['wtf']]})
     except Exception as e:
         E = e
     self.assertTrue(type(E) is InvalidParamsError)
Beispiel #4
0
 def test_validate_args_any(self):
   sig = 'jsonrpc(s1=Any, s2=Any)'
   M = jsonrpc_method(sig, validate=True)(lambda r, s1, s2: s1+s2)
   self.assert_(validate_params(M, {'params': ['omg', 'wtf']}) is None)
   self.assert_(validate_params(M, {'params': [['omg'], ['wtf']]}) is None)
   self.assert_(validate_params(M, {'params': {'s1': 'omg', 's2': 'wtf'}}) is None)
Beispiel #5
0
from jsonrpc import jsonrpc_method


jsonrpc_method('app.register')
def echo(request, param):
    return param