Example #1
0
 def test_errorVersion1(self):
     object = Fault("code", "message")
     result = dumps(object, version=VERSION_1)
     self.assertEquals(
         result,
         ('{"id": null, "result": null, "error": {"fault": "Fault", '
          '"faultCode": "code", "faultString": "message"}}'))
Example #2
0
 def test_errorVersion2(self):
     object = Fault("code", "message")
     result = dumps(object, version=VERSION_2)
     self.assertEquals(
         result,
         ('{"jsonrpc": "2.0", "id": null, "error": {"message": "Fault", '
             '"code": "code", "data": "message"}}'))
Example #3
0
 def test_errorVersionPre1(self):
     object = Fault("code", "message")
     result = dumps(object, version=VERSION_PRE1)
     self.assertEquals(
         result,
         ('{"fault": "Fault", "faultCode": "code", '
          '"faultString": "message"}'))
Example #4
0
 def test_noVersionError(self):
     object = Fault("code", "message")
     result = dumps(object)
     self.assertEquals(
         result,
         ('{"fault": "Fault", "faultCode": "code", '
          '"faultString": "message"}'))
Example #5
0
    def test_errorVersionPre1(self):
        expected = {
            "fault": "Fault",
            "faultCode": "code",
            "faultString": "message"
        }

        fault = Fault("code", "message")
        result = dumps(fault, version=VERSION_PRE1)
        json_result = json.loads(result)

        self.assertEquals(expected, json_result)
Example #6
0
    def test_noVersionError(self):
        expected = {
            "fault": "Fault",
            "faultCode": "code",
            "faultString": "message"
        }

        fault = Fault("code", "message")
        result = dumps(fault)
        json_result = json.loads(result)

        self.assertEquals(expected, json_result)
Example #7
0
    def test_FaultLoads(self):
        dl = []
        for version in (VERSION_PRE1, VERSION_2, VERSION_1):
            object = Fault("code", "message")
            d = defer.maybeDeferred(loads, dumps(object, version=version))
            d = self.assertFailure(d, Fault)

            def callback(exc):
                self.assertEquals(exc.faultCode, object.faultCode)
                self.assertEquals(exc.faultString, object.faultString)
            d.addCallback(callback)

            dl.append(d)
        return defer.DeferredList(dl, fireOnOneErrback=True)
Example #8
0
    def test_errorVersion2(self):
        expected = {
            'jsonrpc': '2.0',
            'id': None,
            'error': {
                'message': 'message',
                'code': 'code',
                'data': 'message'
            }
        }

        fault = Fault('code', 'message')
        result = dumps(fault, version=VERSION_2)
        json_result = json.loads(result)

        self.assertEquals(expected, json_result)