From 0d932feedb442905c42eda56b75354570cf2b6f0 Mon Sep 17 00:00:00 2001 From: aftermath2 Date: Sun, 7 Jul 2024 10:40:57 -0300 Subject: [PATCH] Set cancel_status if it's not None --- frontend/src/components/TradeBox/index.tsx | 2 +- frontend/src/models/Order.model.ts | 1 + tests/test_trade_pipeline.py | 9 +++++++++ tests/utils/trade.py | 4 +++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/TradeBox/index.tsx b/frontend/src/components/TradeBox/index.tsx index 07003020..b14dcea1 100644 --- a/frontend/src/components/TradeBox/index.tsx +++ b/frontend/src/components/TradeBox/index.tsx @@ -203,7 +203,7 @@ const TradeBox = ({ currentOrder, onStartAgain }: TradeBoxProps): JSX.Element => mining_fee_rate, statement, rating, - cancel_status + cancel_status }) .then((data: Order) => { setOpen(closeAll); diff --git a/frontend/src/models/Order.model.ts b/frontend/src/models/Order.model.ts index ede9e4bd..acae1da3 100644 --- a/frontend/src/models/Order.model.ts +++ b/frontend/src/models/Order.model.ts @@ -21,6 +21,7 @@ export interface SubmitActionProps { statement?: string; rating?: number; amount?: number; + cancel_status?: number; } export interface TradeRobotSummary { diff --git a/tests/test_trade_pipeline.py b/tests/test_trade_pipeline.py index 82046363..f7252bfe 100644 --- a/tests/test_trade_pipeline.py +++ b/tests/test_trade_pipeline.py @@ -1085,6 +1085,9 @@ class TradeTest(BaseAPITestCase): trade.cancel_order(trade.maker_index) data = trade.response.json() + self.assertEqual( + data["bad_request"], "This order has been cancelled by the maker" + ) trade.get_order(trade.taker_index) data = trade.response.json() @@ -1092,6 +1095,12 @@ class TradeTest(BaseAPITestCase): data["bad_request"], "This order has been cancelled by the maker" ) + trade.get_order(trade.third_index) + data = trade.response.json() + self.assertEqual( + data["bad_request"], "This order has been cancelled by the maker" + ) + def test_cancel_order_cancel_status(self): """ Tests the cancellation of a public order using cancel_status. diff --git a/tests/utils/trade.py b/tests/utils/trade.py index 85b948eb..3c74f6d9 100644 --- a/tests/utils/trade.py +++ b/tests/utils/trade.py @@ -118,7 +118,9 @@ class Trade: path = reverse("order") params = f"?order_id={self.order_id}" headers = self.get_robot_auth(robot_index) - body = {"action": "cancel", "cancel_status": cancel_status} + body = {"action": "cancel"} + if cancel_status is not None: + body.update({"cancel_status": cancel_status}) self.response = self.client.post(path + params, body, **headers) @patch("api.tasks.send_notification.delay", send_notification)