Example #1
0
 def test_validate_args_any(self):
     sig = 'jsonrpc(s1=Any, s2=Any)'
     M = jsonrpc.method(sig, validate=True)(lambda s1, s2: s1 + s2)
     self.assertTrue(validate_params(M, {'params': ['omg', 'wtf']}) is None)
     self.assertTrue(
         validate_params(M, {'params': [['omg'], ['wtf']]}) is None)
     self.assertTrue(
         validate_params(M, {'params': {
             's1': 'omg',
             's2': 'wtf'
         }}) is None)
    def test_validate_args(self):
        sig = 'jsonrpc(String, String) -> String'
        M = jsonrpc.method(sig, validate=True)(lambda s1, s2: s1+s2)
        self.assertTrue(validate_params(M, {'params': ['omg', 'wtf']}) is None)

        E = None
        try:
            validate_params(M, {'params': [['omg'], ['wtf']]})
        except Exception as e:
            E = e
        self.assertTrue(type(E) is InvalidParamsError)
Example #3
0
    def test_validate_args(self):
        sig = 'jsonrpc(String, String) -> String'
        M = jsonrpc.method(sig, validate=True)(lambda s1, s2: s1 + s2)
        self.assertTrue(validate_params(M, {'params': ['omg', 'wtf']}) is None)

        E = None
        try:
            validate_params(M, {'params': [['omg'], ['wtf']]})
        except Exception as e:
            E = e
        self.assertTrue(type(E) is InvalidParamsError)
 def test_validate_args_any(self):
     sig = 'jsonrpc(s1=Any, s2=Any)'
     M = jsonrpc.method(sig, validate=True)(lambda s1, s2: s1+s2)
     self.assertTrue(validate_params(M, {'params': ['omg', 'wtf']}) is None)
     self.assertTrue(validate_params(M, {'params': [['omg'], ['wtf']]}) is None)
     self.assertTrue(validate_params(M, {'params': {'s1': 'omg', 's2': 'wtf'}}) is None)