From 19032754aa653cd8ad93e196193e737312b75f99 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Wed, 29 Nov 2023 12:03:18 +0000 Subject: [PATCH] Add tests for frontend urls --- frontend/urls.py | 4 ++-- tests/test_frontend_fetch.py | 19 +++++++++++++++++++ tests/utils/trade.py | 4 +++- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/test_frontend_fetch.py diff --git a/frontend/urls.py b/frontend/urls.py index a45fd59b..bff106f3 100644 --- a/frontend/urls.py +++ b/frontend/urls.py @@ -3,7 +3,7 @@ from django.urls import path from .views import basic, pro urlpatterns = [ - path("", basic), + path("", basic, name="basic"), path("create/", basic), path("robot/", basic), path("robot/", basic), @@ -11,5 +11,5 @@ urlpatterns = [ path("order/", basic), path("settings/", basic), path("", basic), - path("pro/", pro), + path("pro/", pro, name="pro"), ] diff --git a/tests/test_frontend_fetch.py b/tests/test_frontend_fetch.py new file mode 100644 index 00000000..d663dade --- /dev/null +++ b/tests/test_frontend_fetch.py @@ -0,0 +1,19 @@ +from django.test import Client, TestCase +from django.urls import reverse + + +class FrontendFetchTest(TestCase): + def setUp(self): + self.client = Client() + + def test_basic_frontend_url_content(self): + path = reverse("basic") + response = self.client.get(path) + self.assertContains(response, "") + self.assertContains(response, "main.js") + + def test_pro_frontend_url_content(self): + path = reverse("pro") + response = self.client.get(path) + self.assertContains(response, "") + self.assertContains(response, "pro.js") diff --git a/tests/utils/trade.py b/tests/utils/trade.py index bc505afb..b00d0ae7 100644 --- a/tests/utils/trade.py +++ b/tests/utils/trade.py @@ -5,7 +5,7 @@ from django.urls import reverse from api.management.commands.clean_orders import Command as CleanOrders from api.management.commands.follow_invoices import Command as FollowInvoices from api.models import Order -from api.tasks import follow_send_payment +from api.tasks import follow_send_payment, send_notification from tests.utils.node import ( add_invoice, create_address, @@ -111,6 +111,7 @@ class Trade: headers = self.get_robot_auth(robot_index, first_encounter) self.response = self.client.get(path + params, **headers) + @patch("api.tasks.send_notification.delay", send_notification) def cancel_order(self, robot_index=1): path = reverse("order") params = f"?order_id={self.order_id}" @@ -144,6 +145,7 @@ class Trade: generate_blocks(create_address("robot"), 1) wait_nodes_sync() + @patch("api.tasks.send_notification.delay", send_notification) def publish_order(self): # Maker's first order fetch. Should trigger maker bond hold invoice generation. self.get_order()