Пример #1
0
    def testWeight(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addWeightCriteria("c")
        v = IValidity(self.shop.c)

        self.assertEqual(v.isValid(), False)
        
        view = getMultiAdapter((
            self.shop.products.product_1, 
            self.shop.products.product_1.REQUEST), name="addToCart")

        view.addToCart()

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

        view.addToCart()
        
        self.assertEqual(v.isValid(), True)

        self.shop.c.setWeight(29.0)
        self.assertEqual(v.isValid(), True)

        self.shop.c.setWeight(30.0)
        self.assertEqual(v.isValid(), False)
Пример #2
0
 def testIsValid_2(self):
     """With one invalid criterion.
     """
     self.default_tax.invokeFactory("DateCriteria", id="date_criterion")
     start = end = DateTime() + 1
     self.default_tax.date_criterion.setStart(start)
     self.default_tax.date_criterion.setEnd(end)
     
     v = IValidity(self.default_tax)
     self.assertEqual(v.isValid(self.product_1), False)
Пример #3
0
    def testIsValid_2(self):
        """With one invalid criterion.
        """
        self.default_tax.invokeFactory("DateCriteria", id="date_criterion")
        start = end = DateTime() + 1
        self.default_tax.date_criterion.setStart(start)
        self.default_tax.date_criterion.setEnd(end)

        v = IValidity(self.default_tax)
        self.assertEqual(v.isValid(self.product_1), False)
Пример #4
0
    def testCategory(self):
        """
        """
        c1_path = "/".join(
            self.portal.shop.categories.category_1.getPhysicalPath())
        c2_path = "/".join(
            self.portal.shop.categories.category_2.getPhysicalPath())
        c11_path = "/".join(self.portal.shop.categories.category_1.category_11.
                            getPhysicalPath())

        # Criteria has one catogory, products have this too
        self.folder.manage_addProduct["iqpp.easyshop"].addCategoryCriteria("c")
        self.folder.c.setCategories((c11_path, ))
        v = IValidity(self.folder.c)

        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)

        # Criteria has one catogory, products haven't this
        self.folder.c.setCategories((c2_path, ))
        v = IValidity(self.folder.c)
        self.assertEqual(v.isValid(self.product_1), False)
        self.assertEqual(v.isValid(self.product_2), False)

        # Criteria has two catogories; products have just one of these
        self.folder.c.setCategories((c11_path, c1_path))
        v = IValidity(self.folder.c)
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)
Пример #5
0
 def testValidity(self):
     """
     """
     self.shop.setPayPalId("")
     paypal = self.shop.paymentmethods.paypal
     result = IValidity(paypal).isValid()        
     self.failUnless(result == False)
     
     self.shop.setPayPalId("*****@*****.**")
     result = IValidity(paypal).isValid()
     self.failUnless(result == True)        
    def testIsValid_3(self):
        """With one valid criterion.
        """
        # Note product_1 costs 22.00
        # price criterion is true if cart price > criterion price
        self.shipping_price.invokeFactory("PriceCriteria", id="price_criterion")
        self.shipping_price.price_criterion.setPrice(21.0)

        view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart")
        view.addToCart()
        
        v = IValidity(self.shop.shippingprices.shipping_price)
        self.assertEqual(v.isValid(), True)
Пример #7
0
    def testPrice(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addPriceCriteria("c")
        v = IValidity(self.shop.c)

        self.login("newmember")

        self.assertEqual(v.isValid(), True)

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

        view.addToCart()
        self.assertEqual(v.isValid(), True)

        self.shop.c.setPrice(23.00)
        self.assertEqual(v.isValid(), False)

        self.shop.c.setPrice(22.00)
        self.assertEqual(v.isValid(), True)

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

        view.addToCart()

        self.shop.c.setPrice(42.00)
        self.assertEqual(v.isValid(), False)

        self.shop.c.setPrice(41.00)
        self.assertEqual(v.isValid(), True)
Пример #8
0
 def testIsValid_4(self):
     """With one invalid and one valid criterion.
     """
     # invalid
     self.default_tax.invokeFactory("DateCriteria", id="date_criterion")    
     start = end = DateTime() + 1
     self.default_tax.date_criterion.setStart(start)
     self.default_tax.date_criterion.setEnd(end)
     
     # valid (product_1 is in group_1; see utils.createTestEnvironment)
     self.default_tax.invokeFactory("GroupCriteria", id="group_criterion")
     self.default_tax.group_criterion.setGroups(["group_1"])        
     v = IValidity(self.default_tax)
     self.assertEqual(v.isValid(self.product_1), False)
Пример #9
0
    def testIsValid_4(self):
        """With one invalid and one valid criterion.
        """
        # invalid
        self.default_tax.invokeFactory("DateCriteria", id="date_criterion")
        start = end = DateTime() + 1
        self.default_tax.date_criterion.setStart(start)
        self.default_tax.date_criterion.setEnd(end)

        # valid (product_1 is in group_1; see utils.createTestEnvironment)
        self.default_tax.invokeFactory("GroupCriteria", id="group_criterion")
        self.default_tax.group_criterion.setGroups(["group_1"])
        v = IValidity(self.default_tax)
        self.assertEqual(v.isValid(self.product_1), False)
Пример #10
0
    def testProduct(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addProductCriteria("c")
        v = IValidity(self.shop.c)

        self.assertEqual(v.isValid(self.product_1), False)

        self.shop.c.setProducts(("product_1", ))
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), False)

        self.shop.c.setProducts(("product_1", "product_2"))
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)
Пример #11
0
    def testProduct(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addProductCriteria("c")
        v = IValidity(self.shop.c)

        self.assertEqual(v.isValid(self.product_1), False)
        
        self.shop.c.setProducts(("product_1",))
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), False)

        self.shop.c.setProducts(("product_1", "product_2"))
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)
Пример #12
0
    def testIsValid_3(self):
        """With one valid criterion.
        """
        # Note product_1 costs 22.00
        # price criterion is true if cart price > criterion price
        self.shipping_price.invokeFactory("PriceCriteria",
                                          id="price_criterion")
        self.shipping_price.price_criterion.setPrice(21.0)

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

        v = IValidity(self.shop.shippingprices.shipping_price)
        self.assertEqual(v.isValid(), True)
Пример #13
0
    def testDate(self):
        """
        """
        self.folder.manage_addProduct["iqpp.easyshop"].addDateCriteria("c")
        v = IValidity(self.folder.c)
        
        self.folder.c.setStart(DateTime()-2)
        self.folder.c.setEnd(DateTime()-1)            
        self.assertEqual(v.isValid(), False)

        self.folder.c.setStart(DateTime()-2)
        self.folder.c.setEnd(DateTime()+1)            
        self.assertEqual(v.isValid(), True)

        self.folder.c.setStart(DateTime()+1)
        self.folder.c.setEnd(DateTime()+2)            
        self.assertEqual(v.isValid(), False)
Пример #14
0
    def testDate(self):
        """
        """
        self.folder.manage_addProduct["iqpp.easyshop"].addDateCriteria("c")
        v = IValidity(self.folder.c)

        self.folder.c.setStart(DateTime() - 2)
        self.folder.c.setEnd(DateTime() - 1)
        self.assertEqual(v.isValid(), False)

        self.folder.c.setStart(DateTime() - 2)
        self.folder.c.setEnd(DateTime() + 1)
        self.assertEqual(v.isValid(), True)

        self.folder.c.setStart(DateTime() + 1)
        self.folder.c.setEnd(DateTime() + 2)
        self.assertEqual(v.isValid(), False)
Пример #15
0
    def testCustomer(self):
        """
        """
        # customer criteria needs context
        self.folder.manage_addProduct["iqpp.easyshop"].addCustomerCriteria("c")
        v = IValidity(self.folder.c)        

        self.assertEqual(v.isValid(), False)

        self.folder.c.setCustomers(("newmember",))
        self.assertEqual(v.isValid(), False)            
        
        self.login("newmember")
        self.assertEqual(v.isValid(), True)        
                
        self.folder.c.setCustomers(("newmember", "anothermember"))        
        self.assertEqual(v.isValid(), True)    
Пример #16
0
    def testPaymentMethod(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addPaymentMethodCriteria(
            "c")
        v = IValidity(self.shop.c)

        self.login("newmember")

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

        customer.selected_payment_method = u"cash-on-delivery"
        self.assertEqual(v.isValid(), False)

        customer.selected_payment_method = u"prepayment"
        self.assertEqual(v.isValid(), False)

        self.shop.c.setPaymentMethods(["direct-debit"])
        self.assertEqual(v.isValid(), False)

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

        self.shop.c.setPaymentMethods(["prepayment", "direct-debit"])
        self.assertEqual(v.isValid(), True)
Пример #17
0
    def testPrice(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addPriceCriteria("c")
        v = IValidity(self.shop.c)
        
        self.login("newmember")        

        self.assertEqual(v.isValid(), True)
        
        view = getMultiAdapter((
            self.shop.products.product_1, 
            self.shop.products.product_1.REQUEST), name="addToCart")
            
        view.addToCart()
        self.assertEqual(v.isValid(), True)

        self.shop.c.setPrice(23.00)
        self.assertEqual(v.isValid(), False)
        
        self.shop.c.setPrice(22.00)
        self.assertEqual(v.isValid(), True)

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

        self.shop.c.setPrice(42.00)
        self.assertEqual(v.isValid(), False)

        self.shop.c.setPrice(41.00)
        self.assertEqual(v.isValid(), True)
Пример #18
0
    def testCountry(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addCountryCriteria("c")
        self.shop.c.setCountries((u"USA", ))
        v = IValidity(self.shop.c)

        self.login("newmember")

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

        customer.invokeFactory("Address", "address_1")

        customer.address_1.country = u"USA"
        self.assertEqual(v.isValid(), True)

        customer.address_1.country = u"Germany"
        self.assertEqual(v.isValid(), False)
Пример #19
0
    def testCountry(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addCountryCriteria("c")
        self.shop.c.setCountries((u"USA",))
        v = IValidity(self.shop.c)
        
        self.login("newmember")

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

        customer.address_1.country = u"USA"
        self.assertEqual(v.isValid(), True)

        customer.address_1.country = u"Germany"
        self.assertEqual(v.isValid(), False)
 def testIsValid_4(self):
     """With one invalid and one valid criterion.
     """
     # Note product_1 costs 22.00
     # price criterion is true if cart price > criterion price
     
     # valid
     self.shipping_price.invokeFactory("PriceCriteria", id="price_criterion")
     self.shipping_price.price_criterion.setPrice(23.0)
     view = getMultiAdapter((self.shop.products.product_1, self.shop.products.product_1.REQUEST), name="addToCart")
     view.addToCart()
     
     # invalid
     self.shipping_price.invokeFactory("DateCriteria", id="date_criterion")
     start = end = DateTime() + 1
     self.shipping_price.date_criterion.setStart(start)
     self.shipping_price.date_criterion.setStart(end)
             
     v = IValidity(self.shop.shippingprices.shipping_price)
     self.assertEqual(v.isValid(), False)
Пример #21
0
    def testGroup(self):
        """
        """
        self.folder.manage_addProduct["iqpp.easyshop"].addGroupCriteria("c")
        v = IValidity(self.folder.c)

        self.assertEqual(v.isValid(self.product_1), False)
        self.assertEqual(v.isValid(self.product_2), False)
                
        self.folder.c.setGroups(("group_1"),)
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)
        
        self.folder.c.setGroups(("group_2"),)        
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), False)
        
        self.folder.c.setGroups(("group_1", "group_2"),)        
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)
Пример #22
0
    def testAdapters(self):
        """
        """
        adapter = IValidity(BankAccount("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(GenericPaymentMethod("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(PaymentPrice("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(CustomerTax("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(DefaultTax("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")

        adapter = IValidity(ShippingPrice("dummy"))
        self.assertEqual(str(adapter.__class__),
                         "<class 'easyshop.shop.adapters.validity.Validity'>")
Пример #23
0
    def testWeight(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addWeightCriteria("c")
        v = IValidity(self.shop.c)

        self.assertEqual(v.isValid(), False)

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

        view.addToCart()

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

        view.addToCart()

        self.assertEqual(v.isValid(), True)

        self.shop.c.setWeight(29.0)
        self.assertEqual(v.isValid(), True)

        self.shop.c.setWeight(30.0)
        self.assertEqual(v.isValid(), False)
Пример #24
0
    def testPaymentMethod(self):
        """
        """
        self.shop.manage_addProduct["iqpp.easyshop"].addPaymentMethodCriteria("c")
        v = IValidity(self.shop.c)
        
        self.login("newmember")

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

        customer.selected_payment_method = u"cash-on-delivery"
        self.assertEqual(v.isValid(), False)

        customer.selected_payment_method = u"prepayment"
        self.assertEqual(v.isValid(), False)

        self.shop.c.setPaymentMethods(["direct-debit"])
        self.assertEqual(v.isValid(), False)        

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

        self.shop.c.setPaymentMethods(["prepayment", "direct-debit"])
        self.assertEqual(v.isValid(), True)
Пример #25
0
    def testCategory(self):
        """
        """
        c1_path  = "/".join(self.portal.shop.categories.category_1.getPhysicalPath())
        c2_path  = "/".join(self.portal.shop.categories.category_2.getPhysicalPath())
        c11_path = "/".join(self.portal.shop.categories.category_1.category_11.getPhysicalPath())

        # Criteria has one catogory, products have this too
        self.folder.manage_addProduct["iqpp.easyshop"].addCategoryCriteria("c")
        self.folder.c.setCategories((c11_path,))
        v = IValidity(self.folder.c)
        
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)

        # Criteria has one catogory, products haven't this         
        self.folder.c.setCategories((c2_path,))
        v = IValidity(self.folder.c)
        self.assertEqual(v.isValid(self.product_1), False)
        self.assertEqual(v.isValid(self.product_2), False)

        # Criteria has two catogories; products have just one of these
        self.folder.c.setCategories((c11_path, c1_path))
        v = IValidity(self.folder.c)
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)
Пример #26
0
    def testIsValid_4(self):
        """With one invalid and one valid criterion.
        """
        # Note product_1 costs 22.00
        # price criterion is true if cart price > criterion price

        # valid
        self.shipping_price.invokeFactory("PriceCriteria",
                                          id="price_criterion")
        self.shipping_price.price_criterion.setPrice(23.0)
        view = getMultiAdapter((self.shop.products.product_1,
                                self.shop.products.product_1.REQUEST),
                               name="addToCart")
        view.addToCart()

        # invalid
        self.shipping_price.invokeFactory("DateCriteria", id="date_criterion")
        start = end = DateTime() + 1
        self.shipping_price.date_criterion.setStart(start)
        self.shipping_price.date_criterion.setStart(end)

        v = IValidity(self.shop.shippingprices.shipping_price)
        self.assertEqual(v.isValid(), False)
Пример #27
0
    def testCustomer(self):
        """
        """
        # customer criteria needs context
        self.folder.manage_addProduct["iqpp.easyshop"].addCustomerCriteria("c")
        v = IValidity(self.folder.c)

        self.assertEqual(v.isValid(), False)

        self.folder.c.setCustomers(("newmember", ))
        self.assertEqual(v.isValid(), False)

        self.login("newmember")
        self.assertEqual(v.isValid(), True)

        self.folder.c.setCustomers(("newmember", "anothermember"))
        self.assertEqual(v.isValid(), True)
Пример #28
0
    def testGroup(self):
        """
        """
        self.folder.manage_addProduct["iqpp.easyshop"].addGroupCriteria("c")
        v = IValidity(self.folder.c)

        self.assertEqual(v.isValid(self.product_1), False)
        self.assertEqual(v.isValid(self.product_2), False)

        self.folder.c.setGroups(("group_1"), )
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)

        self.folder.c.setGroups(("group_2"), )
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), False)

        self.folder.c.setGroups(("group_1", "group_2"), )
        self.assertEqual(v.isValid(self.product_1), True)
        self.assertEqual(v.isValid(self.product_2), True)
Пример #29
0
 def testIsValid_1(self):
     """Without criteria
     """
     v = IValidity(self.default_tax)
     self.assertEqual(v.isValid(self.product_1), True)
Пример #30
0
 def testIsValid_1(self):
     """Without criteria
     """
     v = IValidity(self.default_tax)
     self.assertEqual(v.isValid(self.product_1), True)
Пример #31
0
 def testIsValid_1(self):
     """Without criteria
     """
     v = IValidity(self.shipping_price)
     self.assertEqual(v.isValid(), True)
 def testIsValid_1(self):
     """Without criteria
     """
     v = IValidity(self.shipping_price)
     self.assertEqual(v.isValid(), True)