Ejemplo n.º 1
0
    def testPaymentMethod(self):
        """
        """
        self.shop.manage_addProduct["EasyShop"].addPaymentMethodCriteria("c")
        v = IValidity(self.shop.c)

        self.login("newmember")

        cm = ICustomerManagement(self.shop)
        customer = cm.getAuthenticatedCustomer()

        customer.setSelectedPaymentMethod("cash-on-delivery")
        self.assertEqual(v.isValid(), False)

        customer.setSelectedPaymentMethod("prepayment")
        self.assertEqual(v.isValid(), False)

        self.shop.c.setPaymentMethods(["directdebit"])
        self.assertEqual(v.isValid(), False)

        self.shop.c.setPaymentMethods(["prepayment"])
        self.assertEqual(v.isValid(), True)

        self.shop.c.setPaymentMethods(["prepayment", "directdebit"])
        self.assertEqual(v.isValid(), True)
Ejemplo n.º 2
0
    def testPaymentMethod(self):
        """
        """
        self.shop.manage_addProduct["EasyShop"].addPaymentMethodCriteria("c")
        v = IValidity(self.shop.c)
        
        self.login("newmember")

        cm = ICustomerManagement(self.shop)
        customer = cm.getAuthenticatedCustomer()

        customer.setSelectedPaymentMethod("cash-on-delivery")
        self.assertEqual(v.isValid(), False)

        customer.setSelectedPaymentMethod("prepayment")
        self.assertEqual(v.isValid(), False)

        self.shop.c.setPaymentMethods(["directdebit"])
        self.assertEqual(v.isValid(), False)        

        self.shop.c.setPaymentMethods(["prepayment"])
        self.assertEqual(v.isValid(), True)

        self.shop.c.setPaymentMethods(["prepayment", "directdebit"])
        self.assertEqual(v.isValid(), True)
Ejemplo n.º 3
0
 def afterSetUp(self):
     """
     """
     super(TestCustomerManagement, self).afterSetUp()
     self.cm = ICustomerManagement(self.shop)
     
     self.shop.customers.invokeFactory("Customer", "c1")
     self.shop.customers.invokeFactory("Customer", "c2")
     self.shop.customers.invokeFactory("Customer", "c3")
     self.shop.customers.invokeFactory("Customer", "c4")
Ejemplo n.º 4
0
 def testGetSelectedPaymentMethod_2(self):
     """Customer has selected paypal
     """
     cm = ICustomerManagement(self.shop)
     customer = cm.getAuthenticatedCustomer()        
     customer.setSelectedPaymentMethod("paypal")
     
     pm = IPaymentManagement(self.shop)
     result = pm.getSelectedPaymentMethod().getId()
     self.assertEqual(result, "paypal")
Ejemplo n.º 5
0
    def testGetSelectedPaymentMethod_2(self):
        """Customer has selected paypal
        """
        cm = ICustomerManagement(self.shop)
        customer = cm.getAuthenticatedCustomer()
        customer.setSelectedPaymentMethod("paypal")

        pm = IPaymentManagement(self.shop)
        result = pm.getSelectedPaymentMethod().getId()
        self.assertEqual(result, "paypal")
    def afterSetUp(self):
        """
        """
        super(TestDirectDebit, self).afterSetUp()

        self.login("newmember")
        cm = ICustomerManagement(self.shop)
        self.customer = cm.getAuthenticatedCustomer()

        self.customer.invokeFactory("DirectDebit", id="directdebit")
    def afterSetUp(self):
        """
        """
        super(TestDirectDebit, self).afterSetUp()

        self.login("newmember")
        cm = ICustomerManagement(self.shop)
        self.customer = cm.getAuthenticatedCustomer()

        self.customer.invokeFactory(
            "DirectDebit",
            id="directdebit",
        )
Ejemplo n.º 8
0
    def testCountry(self):
        """
        """
        self.shop.manage_addProduct["EasyShop"].addCountryCriteria("c")
        self.shop.c.setCountries(("USA",))
        v = IValidity(self.shop.c)
        
        self.login("newmember")

        cm = ICustomerManagement(self.shop)
        customer = cm.getAuthenticatedCustomer()        
        customer.invokeFactory("Address", "address_1")

        customer.address_1.setCountry("USA")
        self.assertEqual(v.isValid(), True)

        customer.address_1.setCountry("Germany")
        self.assertEqual(v.isValid(), False)
Ejemplo n.º 9
0
    def testCountry(self):
        """
        """
        self.shop.manage_addProduct["EasyShop"].addCountryCriteria("c")
        self.shop.c.setCountries(("USA", ))
        v = IValidity(self.shop.c)

        self.login("newmember")

        cm = ICustomerManagement(self.shop)
        customer = cm.getAuthenticatedCustomer()
        customer.invokeFactory("Address", "address_1")

        customer.address_1.setCountry("USA")
        self.assertEqual(v.isValid(), True)

        customer.address_1.setCountry("Germany")
        self.assertEqual(v.isValid(), False)
Ejemplo n.º 10
0
class TestCustomerManagement(EasyShopTestCase):
    """
    """
    def afterSetUp(self):
        """
        """
        super(TestCustomerManagement, self).afterSetUp()
        self.cm = ICustomerManagement(self.shop)
        
        self.shop.customers.invokeFactory("Customer", "c1")
        self.shop.customers.invokeFactory("Customer", "c2")
        self.shop.customers.invokeFactory("Customer", "c3")
        self.shop.customers.invokeFactory("Customer", "c4")
        
    def testGetAuthenticatedCustomer_1(self):
        """As anonymous, returns standard customer
        """
        self.logout()
        customer = self.cm.getAuthenticatedCustomer()
        self.assertEqual(customer.getId(), "standard-customer")

    def testGetAuthenticatedCustomer_2(self):
        """As member
        """
        self.login("newmember")
        customer = self.cm.getAuthenticatedCustomer()

        self.failUnless(ICustomer.providedBy(customer))
        self.assertEqual(customer.getId(), "newmember")
        
    def testGetCustomers(self):
        """
        """
        ids = [c.getId() for c in self.cm.getCustomers()]
        self.assertEqual(ids, ["c1", "c2", "c3", "c4"])
        
    def testGetCustomerById_1(self):
        """Existing customer
        """
        customer = self.cm.getCustomerById("c1")

        self.assertEqual(customer.getId(), "c1")
        self.failUnless(ICustomer.providedBy(customer))

    def testGetCustomerById_2(self):
        """Non-existing customer
        """
        customer = self.cm.getCustomerById("doe")
        self.assertEqual(customer, None)
        
    def testHasCustomer(self):
        """
        """
        result = self.cm.hasCustomer("c1")
        self.assertEqual(result, True)

        result = self.cm.hasCustomer("doe")
        self.assertEqual(result, False)