Example #1
0
 def test_check_params(self):
     s = Signature(lambda slf, x, y: x, x=Int(), y=Unicode())
     s.check_params([None, 1, u"a"], {})
     self.assertRaises(RpcCheckError, s.check_params,
                       [None, u"a", u"a"], {})
     self.assertRaises(RpcCheckError, s.check_params, [None, 1, 2], {})
     self.assertRaises(RpcCheckError, s.check_params,
                       [None, 1, u"a", 3], {})
Example #2
0
 def test_param_doc(self):
     s = Signature(lambda slf, x: x, x=Int("foo"),
                   returns=Int("bar"))
     self.assertEqual(s.param_doc(), [
         ':param Int x:',
         '    foo',
         ':rtype Int:',
         '    bar'])
Example #3
0
 def test_check_params(self):
     s = Signature(lambda slf, x, y: x, x=Int(), y=Unicode())
     s.check_params([None, 1, u"a"], {})
     self.assertRaises(RpcCheckError, s.check_params, [None, u"a", u"a"],
                       {})
     self.assertRaises(RpcCheckError, s.check_params, [None, 1, 2], {})
     self.assertRaises(RpcCheckError, s.check_params, [None, 1, u"a", 3],
                       {})
Example #4
0
 def test_jsonrpc_signature(self):
     s = Signature(lambda slf, x: unicode(x), x=Int("foo"),
                   returns=Unicode("bar"))
     self.assertEqual(s.jsonrpc_signature(),
                      [['string', 'int']])
Example #5
0
 def test_check_result(self):
     s = Signature(lambda slf, x: x, x=Int("foo"),
                   returns=Int("bar"))
     self.assertEqual(s.check_result(5), 5)
     self.assertRaises(RpcCheckError, s.check_result, 'a')
Example #6
0
 def test_check_params_with_defaults(self):
     s = Signature(lambda slf, x, y=u"default": x,
                   x=Int(), y=Unicode())
     s.check_params([None, 1, u"a"], {})
     s.check_params([None, 1], {})
Example #7
0
 def test_jsonrpc_signature(self):
     s = Signature(lambda slf, x: unicode(x),
                   x=Int("foo"),
                   returns=Unicode("bar"))
     self.assertEqual(s.jsonrpc_signature(), [['string', 'int']])
Example #8
0
 def test_param_doc(self):
     s = Signature(lambda slf, x: x, x=Int("foo"), returns=Int("bar"))
     self.assertEqual(
         s.param_doc(),
         [':param Int x:', '    foo', ':rtype Int:', '    bar'])
Example #9
0
 def test_check_result(self):
     s = Signature(lambda slf, x: x, x=Int("foo"), returns=Int("bar"))
     self.assertEqual(s.check_result(5), 5)
     self.assertRaises(RpcCheckError, s.check_result, 'a')
Example #10
0
 def test_check_params_with_defaults(self):
     s = Signature(lambda slf, x, y=u"default": x, x=Int(), y=Unicode())
     s.check_params([None, 1, u"a"], {})
     s.check_params([None, 1], {})