def isComplete(self): """Checks weather the customer is complete to checkout. Customer completeness means the customer is ready to check out: 1. Invoice address is complete 2. Shipping address is complete 3. Selected payment method is complete 4. There a items in the cart """ # Get shop shop = self.context.getShop() # Get shipping and invoice address adressman = IAddressManagement(self.context) s_addr = adressman.getShippingAddress() if s_addr is None: return False i_addr = adressman.getInvoiceAddress() if i_addr is None: return False # Get payment method payman = IPaymentManagement(self.context) paymeth = payman.getSelectedPaymentMethod() # Get cart of the customer cart = ICartManagement(shop).getCart() # If there is no cart, the customer hasn't selected a product, hence # he is not complete if cart is None: return False im = IItemManagement(cart) # Check all for completeness # if at least one is False customer is not complete, too. for toCheck in s_addr, i_addr, paymeth: if ICompleteness(toCheck).isComplete() == False: return False # check items in cart if im.hasItems() == False: return False return True
def testGetInvoiceAddress(self): """ """ am = IAddressManagement(self.customer) self.assertEqual(am.getInvoiceAddress().getId(), "address_1")