Esempio n. 1
0
 def test_mail_tickets(self):
     order = start_order(self.user, self.account)
     add_tickets(order, self.tickettype.id, 5)
     order.checkout()
     order.purchase()
     create_tickets(order)
     self.assertTrue(mail_order(order.id, fake=True))
Esempio n. 2
0
 def test_mail_bad_address(self):
     self.user.email = "badmail"
     order = start_order(self.user, self.account)
     add_tickets(order, self.tickettype.id, 5)
     order.checkout()
     order.purchase()
     create_tickets(order)
     self.assertFalse(mail_order(order.id, fake=True))
Esempio n. 3
0
def finish_order(order, send_mail=True, as_guest=False):
    """
    Finish the order by creating the tickets and optionally sending them to the user.
    Unlocked orders can not be purchased.
    """
    try:
        order_id = order.id
        # mark order as purchased
        order.purchase()
        # handle ticket creation
        create_tickets(order)
        order.meta['tickets_created'] = datetime.datetime.utcnow().strftime("%d-%m-%Y %H:%M:%S UTC%z")
        transaction.commit()
        # send mail if requested
        if send_mail:
            mail_order.delay(order_id, as_guest=as_guest, auto_retry=True)
        # update tickettype availability in orders
        order = lookup_order_by_id(order_id)
        for tickettype in order.get_ticket_types():
            update_availability.delay(tickettype.id)
    except Exception as e:
        blogger.exception("failed finalizing order %s" % order_id)
        raise e
Esempio n. 4
0
 def test_send_to_invalid_mail(self):
     order = start_order(self.invalid_mail_user, self.account)
     add_tickets(order, self.tickettype.id, 5)
     create_tickets(order)
     self.assertFalse(mail_ticket(1, fake=True))
Esempio n. 5
0
 def test_mail_ticket(self):
     order = start_order(self.user, self.account)
     add_tickets(order, self.tickettype.id, 5)
     create_tickets(order)
     self.assertTrue(mail_ticket(1, fake=True))
Esempio n. 6
0
 def test_created_double_tickets_from_order(self):
     create_tickets(self.order)
     self.assertEqual(len(tickets_from_order(self.order)), 5)