-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a660ea7
commit 491b5df
Showing
2 changed files
with
109 additions
and
0 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 |
---|---|---|
|
@@ -51,6 +51,14 @@ def commonSetUp(self): | |
email="[email protected]", | ||
) | ||
|
||
self.unapproved_club = Club.objects.create( | ||
code="unapproved-club", | ||
name="Unapproved Club", | ||
approved=False, | ||
ghost=False, | ||
email="[email protected]", | ||
) | ||
|
||
self.event1 = Event.objects.create( | ||
code="test-event", | ||
club=self.club1, | ||
|
@@ -59,6 +67,14 @@ def commonSetUp(self): | |
end_time=timezone.now() + timezone.timedelta(days=3), | ||
) | ||
|
||
self.unapproved_event = Event.objects.create( | ||
code="unapproved-event", | ||
club=self.unapproved_club, | ||
name="Unapproved Event", | ||
start_time=timezone.now() + timezone.timedelta(days=2), | ||
end_time=timezone.now() + timezone.timedelta(days=3), | ||
) | ||
|
||
self.ticket_totals = [ | ||
{"type": "normal", "count": 20, "price": 15.0}, | ||
{"type": "premium", "count": 10, "price": 30.0}, | ||
|
@@ -73,6 +89,11 @@ def commonSetUp(self): | |
for _ in range(10) | ||
] | ||
|
||
self.unapproved_tickets = [ | ||
Ticket.objects.create(type="normal", event=self.unapproved_event, price=15.0) | ||
for _ in range(20) | ||
] | ||
|
||
|
||
class TicketEventTestCase(TestCase): | ||
""" | ||
|
@@ -87,6 +108,30 @@ def setUp(self): | |
|
||
def test_create_ticket_offerings(self): | ||
self.client.login(username=self.user1.username, password="test") | ||
|
||
# Test invalid start_time, ticket_drop_time editing | ||
resp = self.client.patch( | ||
reverse("club-events-detail", args=(self.club1.code, self.event1.pk)), | ||
{ | ||
"ticket_drop_time": ( | ||
self.event1.end_time + timezone.timedelta(days=20) | ||
).strftime("%Y-%m-%dT%H:%M:%S%z") | ||
}, | ||
format="json", | ||
) | ||
self.assertEqual(resp.status_code, 400, resp.content) | ||
|
||
resp = self.client.patch( | ||
reverse("club-events-detail", args=(self.club1.code, self.event1.pk)), | ||
{ | ||
"start_time": ( | ||
self.event1.end_time + timezone.timedelta(days=20) | ||
).strftime("%Y-%m-%dT%H:%M:%S%z") | ||
}, | ||
format="json", | ||
) | ||
self.assertEqual(resp.status_code, 400, resp.content) | ||
|
||
qts = { | ||
"quantities": [ | ||
{"type": "_normal", "count": 20, "price": 10}, | ||
|
@@ -277,6 +322,18 @@ def test_create_ticket_offerings_already_owned_or_held(self): | |
) | ||
self.assertEqual(resp.status_code, 403, resp.content) | ||
|
||
# Changing ticket drop time should fail | ||
resp = self.client.patch( | ||
reverse("club-events-detail", args=(self.club1.code, self.event1.pk)), | ||
{ | ||
"ticket_drop_time": ( | ||
timezone.now() + timezone.timedelta(hours=12) | ||
).strftime("%Y-%m-%dT%H:%M:%S%z") | ||
}, | ||
format="json", | ||
) | ||
self.assertEqual(resp.status_code, 400, resp.content) | ||
|
||
def test_issue_tickets(self): | ||
self.client.login(username=self.user1.username, password="test") | ||
args = { | ||
|
@@ -590,6 +647,50 @@ def test_add_to_cart_before_ticket_drop(self): | |
# Tickets should not be added to cart before drop time | ||
self.assertEqual(resp.status_code, 403, resp.content) | ||
|
||
def test_add_to_cart_unapproved_club(self): | ||
self.client.login(username=self.user1.username, password="test") | ||
tickets_to_add = { | ||
"quantities": [ | ||
{"type": "normal", "count": 2}, | ||
] | ||
} | ||
resp = self.client.post( | ||
reverse( | ||
"club-events-add-to-cart", | ||
args=(self.unapproved_club.code, self.unapproved_event.pk), | ||
), | ||
tickets_to_add, | ||
format="json", | ||
) | ||
self.assertEqual(resp.status_code, 403, resp.content) | ||
self.client.login(username=self.user2.username, password="test") | ||
resp = self.client.post( | ||
reverse( | ||
"club-events-add-to-cart", | ||
args=(self.unapproved_club.code, self.unapproved_event.pk), | ||
), | ||
tickets_to_add, | ||
format="json", | ||
) | ||
# Cannot see event | ||
self.assertEqual(resp.status_code, 404, resp.content) | ||
|
||
def test_add_to_cart_nonexistent_club(self): | ||
tickets_to_add = { | ||
"quantities": [ | ||
{"type": "normal", "count": 2}, | ||
] | ||
} | ||
resp = self.client.post( | ||
reverse( | ||
"club-events-add-to-cart", | ||
args=("Random club name", self.unapproved_event.pk), | ||
), | ||
tickets_to_add, | ||
format="json", | ||
) | ||
self.assertEqual(resp.status_code, 404, resp.content) | ||
|
||
def test_remove_from_cart(self): | ||
self.client.login(username=self.user1.username, password="test") | ||
|
||
|
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