'Test encoding and decoding of an declined trade'

def test_encode_decode_declined_trade(self):

    message = MockObject()
    meta_msg = self.market_community.get_meta_message(u'declined-trade')
    trade_payload = DeclinedTradePayload.Implementation(meta_msg, TraderId('abc'), MessageNumber('3'), OrderNumber(4), TraderId('def'), OrderNumber(5), 1234, Timestamp.now())
    message.payload = trade_payload
    (packet,) = self.conversion._encode_declined_trade(message)
    self.assertTrue(packet)
    (_, decoded) = self.conversion._decode_declined_trade(self.get_placeholder_msg(u'declined-trade'), 0, packet)
    self.assertTrue(decoded)
    self.assertEqual(decoded.trader_id, TraderId('abc'))
    self.assertEqual(decoded.recipient_trader_id, TraderId('def'))
