code: def test_on_cancel(mock_exchange_class, cancel_listener):
      exchange = mock_exchange_class.return_value
      exchange.options = ExchangeOptions()
      exchange.id = "fake_exchange_id"
      exchange.name = "bitfinex"
      exchange.clock = mock.Mock()
      exchange.clock.step = 0
      exchange.quote_price = mock.Mock(return_value=Decimal(7000.00))
  
      wallets = [
          Wallet(exchange, 10000 * USD),
          Wallet(exchange, 0 * BTC),
      ]
      portfolio = Portfolio(USD, wallets)
  
      order = Order(
          step=0,
          exchange_pair=ExchangePair(exchange, USD / BTC),
          side=TradeSide.BUY,
          trade_type=TradeType.MARKET,
          quantity=5200.00 * USD,
          portfolio=portfolio,
          price=Decimal(7000.00),
      )
  
      order.attach(cancel_listener)
  
      assert not cancel_listener.listened
      order.cancel()
      assert cancel_listener.listened
  
file_path: tensortrade/tests/tensortrade/unit/oms/orders/test_order_listener.py
imports: import pytest
  import unittest.mock
  from decimal import Decimal
  from tensortrade.oms.orders import OrderListener, Order, TradeType, TradeSide
  from tensortrade.oms.instruments import USD, BTC, ExchangePair
  from tensortrade.oms.wallets import Wallet, Portfolio
  from tensortrade.oms.exchanges import ExchangeOptions
label_desc: Use image node_id 6 for calling a global function with example usage: test_on_cancel(mock_exchange_class, cancel_listener) without return types