'Test encoding and decoding of a cancel order'

def test_encode_decode_cancel_order(self):

    message = MockObject()
    meta_msg = self.market_community.get_meta_message(u'cancel-order')
    cancel_order_payload = CancelOrderPayload.Implementation(meta_msg, TraderId('abc'), MessageNumber('3'), Timestamp.now(), OrderNumber(4), Ttl(2))
    message.payload = cancel_order_payload
    (packet,) = self.conversion._encode_cancel_order(message)
    self.assertTrue(packet)
    (_, decoded) = self.conversion._decode_cancel_order(self.get_placeholder_msg(u'cancel-order'), 0, packet)
    self.assertTrue(decoded)
    self.assertEqual(decoded.order_number, OrderNumber(4))
    self.assertEqual(int(decoded.ttl), 2)
