Skip to content

Commit

Permalink
Fix Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Jun 25, 2024
1 parent 626e091 commit 48bda66
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
21 changes: 3 additions & 18 deletions tests/test_trade_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,7 @@ def test_make_and_take_order(self):
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {str(data['maker_nick'])}, your order was taken by {str(data['taker_nick'])}!🥳",
)
taker_headers = trade.get_robot_auth(trade.taker_index)
response = self.client.get(reverse("notifications"), **taker_headers)
self.assertResponse(response)
notifications_data = list(response.json())
self.assertEqual(notifications_data[0]["order_id"], trade.order_id)
self.assertEqual(
notifications_data[0]["title"],
f"✅ Hey {str(data['taker_nick'])}, you just took the order with ID {str(trade.order_id)}.",
f"✅ Hey {str(data['maker_nick'])}, your order with ID {trade.order_id} is public in the order book.",
)

# Cancel order to avoid leaving pending HTLCs after a successful test
Expand Down Expand Up @@ -882,11 +873,7 @@ def test_public_order_expires(self):
"""
trade = Trade(self.client)
trade.publish_order()

# Change order expiry to now
order = Order.objects.get(id=trade.response.json()["id"])
order.expires_at = datetime.now()
order.save()
trade.expire_order()

# Make orders expire
trade.clean_orders()
Expand Down Expand Up @@ -929,9 +916,7 @@ def test_taken_order_expires(self):
trade.lock_taker_bond()

# Change order expiry to now
order = Order.objects.get(id=trade.response.json()["id"])
order.expires_at = datetime.now()
order.save()
trade.expire_order()

# Make orders expire
trade.clean_orders()
Expand Down
9 changes: 8 additions & 1 deletion tests/utils/trade.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from unittest.mock import patch

from datetime import datetime
from django.urls import reverse

from api.management.commands.clean_orders import Command as CleanOrders
Expand Down Expand Up @@ -263,3 +263,10 @@ def undo_confirm_sent(self, robot_index=1):
headers = self.get_robot_auth(robot_index)
body = {"action": "undo_confirm"}
self.response = self.client.post(path + params, body, **headers)

@patch("api.tasks.send_notification.delay", send_notification)
def expire_order(self):
# Change order expiry to now
order = Order.objects.get(self.order_id)
order.expires_at = datetime.now()
order.save()

0 comments on commit 48bda66

Please sign in to comment.