Esempio n. 1
0
def _string_to_dict(request):
    """Convert a JSON-RPC request string, to a dictionary.

    :param request: The JSON-RPC request string.
    :raises ValueError: If the string cannot be parsed to JSON.
    :returns: The same request in dict form.
    """
    try:
        return json.loads(request)
    except ValueError:
        raise ParseError()
Esempio n. 2
0
 def test_configuration(self):
     ParseError.message = "Error parsing"
     self.assertEqual("Error parsing", str(ParseError()))
     ParseError.message = "Parse error"
Esempio n. 3
0
 def test_str(self):
     self.assertEqual("Parse error", str(ParseError()))
Esempio n. 4
0
 def test_raise(self):
     with self.assertRaises(JsonRpcServerError):
         raise ParseError()
Esempio n. 5
0
 def test_configuration(self):
     ParseError.message = 'Error parsing'
     self.assertEqual('Error parsing', str(ParseError()))
     ParseError.message = 'Parse error'