Beispiel #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], {})
Beispiel #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'])
Beispiel #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],
                       {})
Beispiel #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']])
Beispiel #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')
Beispiel #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], {})
Beispiel #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']])
Beispiel #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'])
Beispiel #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')
Beispiel #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], {})