Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aviupadhyayula committed Jan 2, 2025
1 parent d7f8054 commit a44c5bd
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions backend/tests/clubs/test_ticketing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Event,
Membership,
Ticket,
TicketSettings,
TicketTransactionRecord,
TicketTransferRecord,
)
Expand Down Expand Up @@ -59,6 +60,11 @@ def commonSetUp(self):
end_time=timezone.now() + timezone.timedelta(days=3),
)

self.ticket_settings = TicketSettings.objects.create(
event=self.event1,
order_limit=10,
)

self.ticket_totals = [
{"type": "normal", "count": 20, "price": 15.0},
{"type": "premium", "count": 10, "price": 30.0},
Expand Down Expand Up @@ -212,14 +218,14 @@ def test_create_ticket_offerings_delay_drop(self):
format="json",
)

self.event1.refresh_from_db()
self.ticket_settings.refresh_from_db()

# Drop time should be set
self.assertIsNotNone(self.event1.ticket_drop_time)
self.assertIsNotNone(self.ticket_settings.drop_time)

# Drop time should be 12 hours from initial ticket creation
expected_drop_time = timezone.now() + timezone.timedelta(hours=12)
diff = abs(self.event1.ticket_drop_time - expected_drop_time)
diff = abs(self.ticket_settings.drop_time - expected_drop_time)
self.assertTrue(diff < timezone.timedelta(minutes=5))

# Move Django's internal clock 13 hours forward
Expand Down Expand Up @@ -469,8 +475,8 @@ def test_get_tickets_information(self):
)

def test_get_tickets_before_drop_time(self):
self.event1.ticket_drop_time = timezone.now() + timedelta(days=1)
self.event1.save()
self.ticket_settings.drop_time = timezone.now() + timedelta(days=1)
self.ticket_settings.save()

self.client.login(username=self.user1.username, password="test")
resp = self.client.get(
Expand Down Expand Up @@ -626,8 +632,8 @@ def test_add_to_cart_before_ticket_drop(self):
self.client.login(username=self.user1.username, password="test")

# Set drop time
self.event1.ticket_drop_time = timezone.now() + timedelta(hours=12)
self.event1.save()
self.ticket_settings.drop_time = timezone.now() + timedelta(hours=12)
self.ticket_settings.save()

tickets_to_add = {
"quantities": [
Expand Down

0 comments on commit a44c5bd

Please sign in to comment.