Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test__update_status(self, mock_info):
self.order._update_status(OrderStatus.EXECUTION_COMPLETE)
self.assertEqual(self.order.status_log, [OrderStatus.EXECUTION_COMPLETE])
self.assertEqual(self.order.status, OrderStatus.EXECUTION_COMPLETE)
def test_replace(self, mock_replacing):
self.order.status = OrderStatus.EXECUTABLE
with self.assertRaises(OrderUpdateError):
self.order.replace(1.01)
self.mock_order_type.ORDER_TYPE = OrderTypes.LIMIT
self.mock_order_type.price = 2.02
self.order.replace(1.01)
self.assertEqual(self.order.update_data, {"new_price": 1.01})
mock_replacing.assert_called_with()
with self.assertRaises(OrderUpdateError):
self.order.replace(2.02)
def test_info(self):
self.order.status_log = [OrderStatus.PENDING, OrderStatus.EXECUTION_COMPLETE]
self.assertEqual(
self.order.info,
{
"bet_id": None,
"handicap": self.order.handicap,
"id": self.order.id,
"market_id": self.mock_trade.market_id,
"selection_id": self.mock_trade.selection_id,
"status": None,
"status_log": "Pending, Execution complete",
"trade": self.mock_trade.info,
"order_type": self.mock_order_type.info,
"info": {
"side": self.order.side,
"size_matched": self.order.size_matched,
"size_remaining": self.order.size_remaining,
def test_replace_error(self):
self.mock_order_type.ORDER_TYPE = OrderTypes.LIMIT
self.order.status = OrderStatus.PENDING
with self.assertRaises(OrderUpdateError):
self.order.replace(1.52)
def orders(self) -> list:
return [o for o in self._orders if o.status != OrderStatus.VIOLATION]
def violation(self) -> None:
self._update_status(OrderStatus.VIOLATION)
self.update_data.clear()
def replacing(self) -> None:
self._update_status(OrderStatus.REPLACING)