Add tests for frontend urls

This commit is contained in:
Reckless_Satoshi 2023-11-29 12:03:18 +00:00
parent b1b19d702c
commit 19032754aa
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
3 changed files with 24 additions and 3 deletions

View File

@ -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/<token>", basic),
@ -11,5 +11,5 @@ urlpatterns = [
path("order/<int:orderId>", basic),
path("settings/", basic),
path("", basic),
path("pro/", pro),
path("pro/", pro, name="pro"),
]

View File

@ -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, "<html>")
self.assertContains(response, "main.js")
def test_pro_frontend_url_content(self):
path = reverse("pro")
response = self.client.get(path)
self.assertContains(response, "<html>")
self.assertContains(response, "pro.js")

View File

@ -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()