From 22b211e6cf0ec9e82269249d13bad718208f5974 Mon Sep 17 00:00:00 2001 From: mahigangal Date: Thu, 11 Apr 2024 00:02:36 -0700 Subject: [PATCH] added testing for confirmation page --- Django/communicado/pages/tests.py | 15 ++++++++++++++- Django/communicado/pages/views.py | 2 -- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Django/communicado/pages/tests.py b/Django/communicado/pages/tests.py index c9d3c8fe..d3a7ab5a 100644 --- a/Django/communicado/pages/tests.py +++ b/Django/communicado/pages/tests.py @@ -679,4 +679,17 @@ def test_xyz_page_contains_expected_paragraphs(self): "Join us in this exhilarating adventure as we redefine the way events are experienced and enjoyed. Welcome aboard!" ] for paragraph in expected_paragraphs: - self.assertContains(response, paragraph, html=True) \ No newline at end of file + self.assertContains(response, paragraph, html=True) + + def test_confirmation_page_renders_correctly(self): + response = self.client.get(reverse('confirmation')) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, 'pages/confirmation.html') + + def test_confirmation_page_contains_header_and_message(self): + response = self.client.get(reverse('confirmation')) + self.assertContains(response, '

Confirmation

', html=True) + self.assertContains(response, '

Communicado

', html=True) + self.assertContains(response, '

Your go-to platform for discovering and booking exciting events

', html=True) + + \ No newline at end of file diff --git a/Django/communicado/pages/views.py b/Django/communicado/pages/views.py index a8625baa..ce67b00c 100644 --- a/Django/communicado/pages/views.py +++ b/Django/communicado/pages/views.py @@ -260,7 +260,6 @@ def add_to_cart(request, event_ID): request.session['cart'].append(event_ID) # Important: mark the session as modified to make sure it gets saved request.session.modified = True - messages.success(request, 'Event added to cart successfully!') return redirect('cart') # Update 'cart' with your cart route's name or wherever you want to redirect the user @@ -289,7 +288,6 @@ def payment(request): # Basic validation for cardholder name if not cardholder_name.strip(): raise ValueError('Cardholder name cannot be empty') - # If all validations pass, simulate a successful payment messages.success(request, 'Payment successful and Booking Confirmed! Please look out for a confirmation email with details of your booking.') return redirect('confirmation')