def testAddAddress(self):
        """
        """
        am = IAddressManagement(self.customer)
        id = am.addAddress("Doe Str. 1", "App. 1", "4711", "Doe City",
                           "Germany")

        ids = [a.getId() for a in am.getAddresses()]
        self.assertEqual(ids, ["address_1", "address_2", "address_3", id])
Example #2
0
    def _getAddressesAsDL(self):
        """Returns all addresses as DisplayList.
        """
        dl = DisplayList()

        am = IAddressManagement(self)
        for address in am.getAddresses():
            dl.add(address.getId(), address.getName() + " - " + address.getAddress1())

        return dl
Example #3
0
    def _getAddressesAsDL(self):
        """Returns all addresses as DisplayList.
        """
        dl = DisplayList()

        am = IAddressManagement(self)
        for address in am.getAddresses():
            dl.add(address.getId(),
                   address.getName() + " - " + address.getAddress1())

        return dl
 def testAddAddress(self):
     """
     """
     am = IAddressManagement(self.customer)
     id = am.addAddress(
         "Doe Str. 1",
         "App. 1",
         "4711",
         "Doe City",
         "Germany"
     )
             
     ids = [a.getId() for a in am.getAddresses()]        
     self.assertEqual(ids, ["address_1", "address_2", "address_3", id])
    def testDeleteAddress(self):
        """
        """
        am = IAddressManagement(self.customer)        

        am.deleteAddress("address_1")
        ids = [a.getId() for a in am.getAddresses()]        
        self.assertEqual(ids, ["address_2", "address_3"])

        am.deleteAddress("address_2")
        ids = [a.getId() for a in am.getAddresses()]        
        self.assertEqual(ids, ["address_3"])

        am.deleteAddress("address_3")
        ids = [a.getId() for a in am.getAddresses()]
        self.assertEqual(ids, [])
Example #6
0
    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
Example #7
0
    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
Example #8
0
    def testIsComplete(self):
        """
        """
        c = ICompleteness(self.shop.customers.customer)
        self.assertEqual(c.isComplete(), False)

        am = IAddressManagement(self.customer)
        id = am.addAddress("Doe Str. 1", "App. 1", "4711", "Doe City",
                           "Germany")

        self.customer.setInvoiceAddressAsString(id)
        self.customer.setShippingAddressAsString(id)
        self.assertEqual(c.isComplete(), False)

        view = getMultiAdapter((self.shop.products.product_1,
                                self.shop.products.product_1.REQUEST),
                               name="addToCart")
        view.addToCart()

        self.assertEqual(c.isComplete(), True)
 def testIsComplete(self):
     """
     """        
     c = ICompleteness(self.shop.customers.customer)
     self.assertEqual(c.isComplete(), False)
     
     am = IAddressManagement(self.customer)
     id = am.addAddress(
         "Doe Str. 1",
         "App. 1",
         "4711",
         "Doe City",
         "Germany"
     )
     
     self.customer.setInvoiceAddressAsString(id)        
     self.customer.setShippingAddressAsString(id)
     self.assertEqual(c.isComplete(), False)
     
     view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart")
     view.addToCart()
     
     self.assertEqual(c.isComplete(), True)
 def testGetAddresses(self):
     """
     """
     am = IAddressManagement(self.customer)
     self.assertEqual([], am.getAddresses())
 def testGetAddresses(self):
     """
     """
     am = IAddressManagement(self.customer)
     self.assertEqual([], am.getAddresses())
 def testGetAddresses(self):
     """
     """
     am = IAddressManagement(self.customer)
     ids = [a.getId() for a in am.getAddresses()]
     self.assertEqual(ids, ["address_1", "address_2", "address_3"])
 def testDeleteAddress(self):
     """
     """
     am = IAddressManagement(self.customer)
     result = am.deleteAddress("address_1")
     self.assertEqual(result, False)
 def testGetInvoiceAddress(self):
     """
     """
     am = IAddressManagement(self.customer)
     self.assertEqual(am.getInvoiceAddress().getId(), "address_1")
 def testGetShippingAddress(self):
     """
     """
     am = IAddressManagement(self.customer)
     self.assertEqual(am.getShippingAddress().getId(), "address_2")
 def testGetAddresses(self):
     """
     """
     am = IAddressManagement(self.customer)
     ids = [a.getId() for a in am.getAddresses()]        
     self.assertEqual(ids, ["address_1", "address_2", "address_3"])
 def testDeleteAddress(self):
     """
     """
     am = IAddressManagement(self.customer)        
     result = am.deleteAddress("address_1")
     self.assertEqual(result, False)
 def testGetInvoiceAddress(self):
     """
     """
     am = IAddressManagement(self.customer)
     self.assertEqual(am.getInvoiceAddress().getId(), "address_1")
 def testGetShippingAddress(self):
     """
     """
     am = IAddressManagement(self.customer)
     self.assertEqual(am.getShippingAddress().getId(), "address_2")
    def testDeleteAddress(self):
        """
        """
        am = IAddressManagement(self.customer)

        am.deleteAddress("address_1")
        ids = [a.getId() for a in am.getAddresses()]
        self.assertEqual(ids, ["address_2", "address_3"])

        am.deleteAddress("address_2")
        ids = [a.getId() for a in am.getAddresses()]
        self.assertEqual(ids, ["address_3"])

        am.deleteAddress("address_3")
        ids = [a.getId() for a in am.getAddresses()]
        self.assertEqual(ids, [])