def test_get_tickets_for_class(self): '''get one ticket for everything but master, and one for classes ''' event = ClassFactory() ws_bpt_event = BrownPaperEventsFactory( conference=event.e_conference, include_most=True, title="The Whole Shebang 2016") sch_bpt_event = BrownPaperEventsFactory( conference=event.e_conference, include_conference=True, title="The Scholar 2016") whole_shebang = TicketItemFactory( bpt_event=ws_bpt_event, live=True, has_coupon=False) scholar = TicketItemFactory( bpt_event=sch_bpt_event, live=True, has_coupon=False) tickets = event.get_tickets() self.assertEqual(len(tickets), 2) self.assertEqual( tickets[0], ws_bpt_event) self.assertEqual( tickets[1], sch_bpt_event)
def test_get_tickets_for_class_three_ways(self): '''the ticket is linked to the class event three ways - 'most', 'conference', and a direct link. It only should appear once. ''' event = ClassFactory() ticketing_event = TicketingEventsFactory( conference=event.e_conference, include_most=True, include_conference=True, title="The Whole Shebang 2016") ticketing_event.linked_events.add(event) ticketing_event.save() TicketItemFactory(ticketing_event=ticketing_event, live=True, has_coupon=False) tickets = event.get_tickets() self.assertEqual(len(tickets), 1) self.assertEqual(tickets[0].title, "The Whole Shebang 2016")
def test_get_tickets_nothing_active(self): '''the ticket is linked to the class and there are two active prices only the most expensive is shown ''' event = ClassFactory() ticketing_event = TicketingEventsFactory(conference=event.e_conference, include_conference=True) TicketItemFactory(ticketing_event=ticketing_event, live=False, has_coupon=False, title="The Whole Shebang 2016") TicketItemFactory(ticketing_event=ticketing_event, live=True, has_coupon=True, cost=299.99, title="The Whole Shebang 2016 - expensive") tickets = event.get_tickets() self.assertEqual(len(tickets), 0)
def test_get_tickets_nothing_active(self): '''the ticket is linked to the class and there are two active prices only the most expensive is shown ''' event = ClassFactory() bpt_event = BrownPaperEventsFactory( conference=event.e_conference, include_conference=True) TicketItemFactory(bpt_event=bpt_event, live=False, has_coupon=False, title="The Whole Shebang 2016") TicketItemFactory(bpt_event=bpt_event, live=True, has_coupon=True, cost=299.99, title="The Whole Shebang 2016 - expensive") tickets = event.get_tickets() self.assertEqual(len(tickets), 0)
def test_get_tickets_for_class_three_ways(self): '''the ticket is linked to the class event three ways - 'most', 'conference', and a direct link. It only should appear once. ''' event = ClassFactory() bpt_event = BrownPaperEventsFactory( conference=event.e_conference, include_most=True, include_conference=True, title="The Whole Shebang 2016") bpt_event.linked_events.add(event) bpt_event.save() TicketItemFactory(bpt_event=bpt_event, live=True, has_coupon=False) tickets = event.get_tickets() self.assertEqual(len(tickets), 1) self.assertEqual( tickets[0].title, "The Whole Shebang 2016")