Example #1
0
 def test_encode_invalidErrorCode(self):
     e = Error()
     e._transaction_id = 9052
     # e.code must be in {201, 202, 203}
     e.code = 512
     e.message = ""
     self.assertRaises(InvalidKRPCError, encode, e)
Example #2
0
 def test_encode_invalidErrorCode(self):
     e = Error()
     e._transaction_id = 9052
     # e.code must be in {201, 202, 203}
     e.code = 512
     e.message = ""
     self.assertRaises(InvalidKRPCError, encode, e)
Example #3
0
 def test_repr(self):
     e = Error()
     e._transaction_id = 222
     e.code = 202
     e.message = "Invalid Query"
     expected_repr = ("<Error: _transaction_id=222 " +
                      "code=202 message='Invalid Query'>")
     self.assertEquals(expected_repr, repr(e))
Example #4
0
 def test_repr(self):
     e = Error()
     e._transaction_id = 222
     e.code = 202
     e.message = "Invalid Query"
     expected_repr = ("<Error: _transaction_id=222 " +
                      "code=202 message='Invalid Query'>")
     self.assertEquals(expected_repr, repr(e))
Example #5
0
 def test_encode_and_decode_validError(self):
     e = Error()
     e._transaction_id = 129085
     e.code = 202
     e.message = ""
     processed_error = encode_and_decode(e)
     self.assertEquals(e._transaction_id, processed_error._transaction_id)
     self.assertEquals(e.code, processed_error.code)
     self.assertEquals(e.message, processed_error.message)
Example #6
0
 def test_encode_and_decode_validError(self):
     e = Error()
     e._transaction_id = 129085
     e.code = 202
     e.message = ""
     processed_error = encode_and_decode(e)
     self.assertEquals(e._transaction_id, processed_error._transaction_id)
     self.assertEquals(e.code, processed_error.code)
     self.assertEquals(e.message, processed_error.message)
Example #7
0
def _error_decoder(rpc_dict):
    """
    Decode the given KRC dictionary into a valid Error

    @see decode
    @return krpc_types.Error

    """
    e = Error()
    e.code, e.message = rpc_dict['e']
    if e.code not in [201, 202, 203]:
        raise _ProtocolFormatError()
    return e
Example #8
0
def _error_decoder(rpc_dict):
    """
    Decode the given KRC dictionary into a valid Error

    @see decode
    @return krpc_types.Error

    """
    e = Error()
    e.code, e.message = rpc_dict['e']
    if e.code not in [201, 202, 203]:
        raise _ProtocolFormatError()
    return e