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)
def test_should_not_expire_valid_orders(self): """Method to test to not mark valid orders as expired""" with self.app.test_request_context(): obj = OrderFactory() event = EventFactoryBasic() obj.event = event db.session.commit() set_expiry_for_order(obj) self.assertEqual(obj.status, 'initializing')
def test_should_expire_outdated_order(self): """Method to test expiration of outdated orders""" with self.app.test_request_context(): obj = OrderFactory() order_expiry_time = get_settings()['order_expiry_time'] event = EventFactoryBasic() obj.event = event obj.created_at = datetime.now( timezone.utc) - timedelta(minutes=order_expiry_time) set_expiry_for_order(obj) self.assertEqual(obj.status, 'expired')