Skip to content

Commit

Permalink
Merge pull request #222 from MithishR/mahi_test
Browse files Browse the repository at this point in the history
Tests added for Confirmation page
  • Loading branch information
ojusharma authored Apr 11, 2024
2 parents 219cb54 + 22b211e commit 334c938
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 14 additions & 1 deletion Django/communicado/pages/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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, '<h2>Confirmation</h2>', html=True)
self.assertContains(response, '<h1>Communicado</h1>', html=True)
self.assertContains(response, '<p>Your go-to platform for discovering and booking exciting events</p>', html=True)


2 changes: 0 additions & 2 deletions Django/communicado/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 334c938

Please sign in to comment.