Пример #1
0
    def test_send_monthly_invoice(self):
        """Method to test monthly invoices"""

        with self.app.test_request_context():
            TicketFeesFactory(service_fee=10.23, maximum_fee=11)

            test_event = EventFactoryBasic(state='published')

            test_user = UserFactory()

            test_order = OrderFactory(status='completed')
            test_order.completed_at = datetime.datetime.now(
            ) - datetime.timedelta(days=30)
            test_order.amount = 100
            test_order.event = test_event

            test_ticket_holder = AttendeeFactory()
            test_ticket_holder.event = test_event
            test_ticket_holder.order = test_order

            test_event.owner = test_user
            db.session.commit()

            send_monthly_event_invoice()
            event_invoice = EventInvoice.query.get(1)
            self.assertEqual(event_invoice.amount, 10.23)
Пример #2
0
    def test_get_count(self):
        """Method to test the number of queries concerning a Model"""

        with self.app.test_request_context():
            attendee = AttendeeFactory()
            save_to_db(attendee)
            self.assertEqual(get_count(TicketHolder.query), 1)
    def test_export_attendees_csv(self):
        """Method to check the attendees data export"""

        with self.app.test_request_context():
            test_attendee = AttendeeFactory()
            field_data = export_attendees_csv([test_attendee])
            self.assertEqual(field_data[1][3], common.string_)
            self.assertEqual(field_data[1][5], '*****@*****.**')
    def test_delete_ticket_holders_with_no_order_id(self):
        """Method to test deleting ticket holders with no order id after expiry time"""

        with self.app.test_request_context():
            attendee = AttendeeFactory(created_at=common.date_)
            db.session.commit()
            attendee_id = attendee.id
            delete_ticket_holders_no_order_id()
            ticket_holder = TicketHolder.query.get(attendee_id)
            self.assertIs(ticket_holder, None)
    def test_delete_ticket_holder_created_currently(self):
        """Method to test not deleting ticket holders with no order id but created within expiry time"""

        with self.app.test_request_context():
            attendee = AttendeeFactory(created_at=datetime.datetime.utcnow(),
                                       modified_at=datetime.datetime.utcnow())

            db.session.commit()
            attendee_id = attendee.id
            delete_ticket_holders_no_order_id()
            ticket_holder = TicketHolder.query.get(attendee_id)
            self.assertIsNot(ticket_holder, None)
Пример #6
0
    def test_should_delete_related_attendees(self):
        """Method to test to delete related attendees of an event"""

        with app.test_request_context():
            attendee = AttendeeFactory()
            save_to_db(attendee)

            obj = OrderFactory()
            obj.ticket_holders = [attendee, ]
            save_to_db(obj)

            delete_related_attendees_for_order(obj)
            order = db.session.query(Order).filter(Order.id == obj.id).first()
            self.assertEqual(len(order.ticket_holders), 0)
    def test_delete_ticket_holder_with_valid_order_id(self):
        """Method to test not deleting ticket holders with order id after expiry time"""

        with self.app.test_request_context():
            attendee = AttendeeFactory(order_id=1,
                                       ticket_id=1,
                                       created_at=datetime.datetime.utcnow() -
                                       datetime.timedelta(minutes=15),
                                       modified_at=datetime.datetime.utcnow() -
                                       datetime.timedelta(minutes=15))

            db.session.commit()
            attendee_id = attendee.id
            delete_ticket_holders_no_order_id()
            ticket_holder = TicketHolder.query.get(attendee_id)
            self.assertIsNot(ticket_holder, None)
 def test_get_count(self):
     with app.test_request_context():
         attendee = AttendeeFactory()
         save_to_db(attendee)
         self.assertEqual(get_count(TicketHolder.query), 1)