def setUp(self): location = models.Location(title='test_title', street='test_street', city='test_city', postcode='000000', country='test_country', capacity=20) location.save() event = models.Event(title='test_event', description='test', event_type='Event.meetup', cfp_allowed=False, status=models.event.Event.PUBLISHED, location=location, date_from=now, date_to=later) event.save() self.ticket_type = models.TicketType(title='test', description='test', price=100, event=event, date_from=now, date_to=later) self.ticket_type.save() self.ticket_type_2 = models.TicketType(title='secondType', description='otherType', price=7, event=event, date_from=now, date_to=later) self.ticket_type_2.save() self.discount_code = models.DiscountCode(title='test discount', hash='test', discount=60, date_from=now, date_to=later, usage=1, ticket_type=self.ticket_type) self.discount_code.save() self.discount_code_2 = models.DiscountCode( title='discount_2', hash='otherCode', discount=4, usage=100, date_from=now, date_to=later, ticket_type=self.ticket_type_2)
def setUp(self): time = timezone.now() location = models.Location(title='test_title', street='test_street', city='test_city', postcode='000000', state='test_state', capacity=20) location.save() event = models.Event(title='test_event', description='test', event_type='meetup', status=models.event.PUBLISHED, location=location, date_from=time, date_to=time) event.save() self.ticket_type = models.TicketType(title='test', description='test', price=100, event=event, date_from=time, date_to=time) self.ticket_type.save() self.ticket_type_2 = models.TicketType(title='secondType', description='otherType', price=7, event=event, date_from=time, date_to=time) self.ticket_type_2.save() self.discount_code = models.DiscountCode(title='test discount', hash='test', discount=60, date_from=time, date_to=time, usage=1, ticket_type=self.ticket_type) self.discount_code.save() self.discount_code_2 = models.DiscountCode( title='discount_2', hash='otherCode', discount=4, date_from=time, date_to=time, usage=100, ticket_type=self.ticket_type_2)
def test_automatic_order_generator(self): time = timezone.now() location = models.Location(title='test_title', street='test_street', city='test_city', postcode=000000, state='test_state', capacity=20) location.save() event = models.Event(title='test_event', description='test', event_type='meetup', status=models.event.PUBLISHED, location=location, date_from=time, date_to=time) event.save() ticket_type = models.TicketType(title='test', description='test', price=100, event=event, date_from=timezone.now(), date_to=timezone.now()) ticket_type.save() discount_code = models.DiscountCode(title='test discount', hash='test', discount=60, date_from=time, date_to=time, usage=1, ticket_type=ticket_type) discount_code.save() ticket = models.Ticket(status='requested', title='mr', first_name="test", last_name="Test", type=ticket_type, email='*****@*****.**', phone='0912345678', discount_code=discount_code) ticket.save() self.assertEquals(ticket.order.status, 'awaiting_payment') self.assertEquals(ticket.order.price, ticket_type.price) self.assertEquals(ticket.order.discount, 60)