Exemplo n.º 1
0
    def test_full_checkout_with_automatic_cart_discount(self):
        ent = Enterprise.find_by_name('Healthy U Store')
        api = StripeBillingApi(ent)

        # set up the discount for the products
        self.login_crm(PVS_ROOT_UID, PVS_ROOT_PWD)
        discount_id = create_new_cart_discount(self, True)
        discount = Discount.load(discount_id)
        assert discount is not None
        assert int(discount.percent_off) == 10
        self.logout_crm_soft()

        self.login_customer()
        self._clear_cart()

        prod = self.get_prod()
        self._add_product(prod, 100)
        R = self.get('/cart/catalog_cart')
        R.mustcontain('total=2500.0')
        R.mustcontain('product_base_total=2500.0')
        R.mustcontain('product_total=2500.0')
        R.mustcontain('product_discounts=0.0')

        R = self.get('/ecom/cart/update/%s/10' % prod.product_id)
        assert R.status_int == 200
        assert R.body == 'True'

        R = self.get('/cart/catalog_cart')
        R.mustcontain('total=250.0')
        R.mustcontain('product_base_total=250.0')
        R.mustcontain('product_total=250.0')
        R.mustcontain('product_discounts=0.0')

        self._select_shipping()

        R = self.post("/crm/customer/purchase_cart",
                      {'redir' : '/ecom/page/catalog_thanks',
                      'accept_terms' : '1',
                      'bill_cc_token' : api.create_token('4242424242424242', '12', '2019', '123')})

        R.mustcontain('order total_discounts_applied = 0')
        R.mustcontain('order total_payments_due = 0.0')
        R.mustcontain('order total_item_price = 250.0')
        #R.mustcontain('order total_payments_applied = 418.53')
        #R.mustcontain('order total_price = 418.53')
        #R.mustcontain('order total_shipping_price = 18.53')

        self.logout_customer(False)

        self.login_crm(PVS_ROOT_UID, PVS_ROOT_PWD)
        #delete_new_cart_discount(self, discount_id)
        self.logout_crm_soft()
Exemplo n.º 2
0
 def test_purchase_cart(self):
     ent = Enterprise.find_by_name('Healthy U Store')
     api = StripeBillingApi(ent)
     self._clear_cart()
     prod = self.get_prod()
     self._add_product(prod, 2)
     R = self.get('/cart/catalog_cart')
     assert R.status_int == 200
     assert 'product_id=%s' % prod.product_id in R.body
     assert 'quantity=%s/2.0' % prod.product_id in R.body
     R = self.get('/ecom/cart/update/%s/9' % prod.product_id)
     assert R.status_int == 200
     assert R.body == 'True'
     R = self.get('/cart/catalog_cart')
     assert R.status_int == 200
     assert 'product_id=%s' % prod.product_id in R.body
     assert 'quantity=%s/9.0' % prod.product_id in R.body
     R = self.post("/crm/customer/purchase_cart",
                   {'redir' : '/ecom/page/catalog_thanks',
                   'accept_terms' : '1',
                   'bill_cc_token' : api.create_token('4242424242424242', '12', '2019', '123')})
     assert R.status_int == 200
     R.mustcontain('Thanks for your purchase')