-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix so that the start_payment correctly associates the tickets with a…
… chapter event. Contains limited functionality that allows foor buying tickets for several different chapter events at once.
- Loading branch information
Showing
2 changed files
with
45 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,13 @@ | |
from datetime import datetime | ||
from django.utils import timezone | ||
|
||
from bittan.models import TicketType, ChapterEvent, Payment | ||
from bittan.models import TicketType, ChapterEvent, Ticket, Payment | ||
|
||
class StartPaymentTest(TestCase): | ||
def setUp(self): | ||
NOW = timezone.now() | ||
self.test_event = ChapterEvent.objects.create(title="Test Event", description="An event for testing. ", total_seats=10, sales_stop_at=NOW+timezone.timedelta(days=365), event_at=NOW+timezone.timedelta(days=366)) | ||
self.test_event = ChapterEvent.objects.create(title="Test Event1", description="An event for testing. ", total_seats=10, sales_stop_at=NOW+timezone.timedelta(days=365), event_at=NOW+timezone.timedelta(days=366)) | ||
self.test_event2 = ChapterEvent.objects.create(title="Test Event2", description="An event for testing. ", total_seats=10, sales_stop_at=NOW+timezone.timedelta(days=365), event_at=NOW+timezone.timedelta(days=366), reservation_duration=timezone.timedelta(minutes=30)) | ||
|
||
self.test_ticket = TicketType.objects.create(price=200, title="Test Ticket", description="A ticket for testing.") | ||
self.test_event.ticket_types.add(self.test_ticket) | ||
|
@@ -37,6 +38,26 @@ def setUp(self): | |
content_type="application/json" | ||
) | ||
|
||
# Temporary setup as the reserve_ticket view does not support reserving tickets for several different ChapterEvents at once. | ||
payment_id = self.client.session["reserved_payment"] | ||
payment = Payment.objects.get(pk=payment_id) | ||
second_event_ticket1 = Ticket.objects.create( | ||
external_id = "1234", | ||
time_created = NOW, | ||
payment = payment, | ||
ticket_type = self.test_ticket, | ||
chapter_event = self.test_event2 | ||
) | ||
second_event_ticket2 = Ticket.objects.create( | ||
external_id = "1111", | ||
time_created = NOW, | ||
payment = payment, | ||
ticket_type = self.test_ticket2, | ||
chapter_event = self.test_event2 | ||
) | ||
|
||
|
||
|
||
def test_start_payment(self): | ||
mail_address = "[email protected]" | ||
response = self.client.post( | ||
|
@@ -134,7 +155,7 @@ def test_expired_session_rebook_tickets(self, mock_now): | |
self.assertEqual(payment.payment_started, True) | ||
self.assertEqual(payment.email, mail_address) | ||
self.assertEqual(payment.status, PaymentStatus.RESERVED) | ||
self.assertEqual(payment.expires_at, now + self.test_event.reservation_duration) | ||
self.assertEqual(payment.expires_at, now + self.test_event2.reservation_duration) | ||
|
||
def test_double_payment(self): | ||
mail_address = "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters