Пример #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)
Пример #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)
Пример #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))
Пример #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))
Пример #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)
Пример #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)
Пример #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
Пример #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