Commit 2df797b7 authored by Ivan Tyagov's avatar Ivan Tyagov

Between tests steps all temporary objects are cleaned up.

Make sure that each test step creates all needed products/shipping
so they are not dependant any more.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19557 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 4db6032a
...@@ -132,9 +132,10 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -132,9 +132,10 @@ class TestCommerce(ERP5TypeTestCase):
default_product = self.getDefaultProduct() default_product = self.getDefaultProduct()
request.set('session_id', SESSION_ID) request.set('session_id', SESSION_ID)
# add second (same) product and check that we do not create # add in two speps same product and check that we do not create
# new Sale Order Line but just increase quantity on existing one # new Sale Order Line but just increase quantity on existing one
portal.Resource_addToShoppingCart(default_product, 1) portal.Resource_addToShoppingCart(default_product, 1)
portal.Resource_addToShoppingCart(default_product, 1)
shoppping_cart_items = portal.SaleOrder_getShoppingCartItemList() shoppping_cart_items = portal.SaleOrder_getShoppingCartItemList()
self.assertEquals(1, len(shoppping_cart_items)) self.assertEquals(1, len(shoppping_cart_items))
self.assertEquals(2, shoppping_cart_items[0].getQuantity()) self.assertEquals(2, shoppping_cart_items[0].getQuantity())
...@@ -153,16 +154,21 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -153,16 +154,21 @@ class TestCommerce(ERP5TypeTestCase):
LOG('Testing... ', 0, message) LOG('Testing... ', 0, message)
portal = self.getPortal() portal = self.getPortal()
request = self.app.REQUEST request = self.app.REQUEST
default_product = self.getDefaultProduct(id = '2') default_product = self.getDefaultProduct()
another_product = self.getDefaultProduct(id = '2')
request.set('session_id', SESSION_ID) request.set('session_id', SESSION_ID)
# add second diff product and check that we create new Sale Order Line # add second diff product and check that we create new Sale Order Line
portal.Resource_addToShoppingCart(default_product, 1) portal.Resource_addToShoppingCart(default_product, 2)
portal.Resource_addToShoppingCart(another_product, 1)
shoppping_cart_items = portal.SaleOrder_getShoppingCartItemList() shoppping_cart_items = portal.SaleOrder_getShoppingCartItemList()
self.assertEquals(2, len(shoppping_cart_items)) self.assertEquals(2, len(shoppping_cart_items))
self.assertEquals(2, shoppping_cart_items[0].getQuantity())
self.assertEquals(1, shoppping_cart_items[1].getQuantity()) self.assertEquals(1, shoppping_cart_items[1].getQuantity())
self.assertEquals(shoppping_cart_items[1].getResource(), \ self.assertEquals(shoppping_cart_items[0].getResource(), \
default_product.getRelativeUrl()) default_product.getRelativeUrl())
self.assertEquals(shoppping_cart_items[1].getResource(), \
another_product.getRelativeUrl())
def test_04_CalculateTotaShoppingCartPrice(self, quiet=0, run=run_all_test): def test_04_CalculateTotaShoppingCartPrice(self, quiet=0, run=run_all_test):
...@@ -178,7 +184,11 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -178,7 +184,11 @@ class TestCommerce(ERP5TypeTestCase):
portal = self.getPortal() portal = self.getPortal()
request = self.app.REQUEST request = self.app.REQUEST
default_product = self.getDefaultProduct() default_product = self.getDefaultProduct()
another_product = self.getDefaultProduct(id = '2')
request.set('session_id', SESSION_ID) request.set('session_id', SESSION_ID)
portal.Resource_addToShoppingCart(default_product, 2)
portal.Resource_addToShoppingCart(another_product, 1)
shopping_cart = portal.SaleOrder_getShoppingCart() shopping_cart = portal.SaleOrder_getShoppingCart()
self.assertEquals(40.0, \ self.assertEquals(40.0, \
float(shopping_cart.SaleOrder_getShoppingCartTotalPrice())) float(shopping_cart.SaleOrder_getShoppingCartTotalPrice()))
...@@ -212,9 +222,16 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -212,9 +222,16 @@ class TestCommerce(ERP5TypeTestCase):
LOG('Testing... ', 0, message) LOG('Testing... ', 0, message)
portal = self.getPortal() portal = self.getPortal()
request = self.app.REQUEST request = self.app.REQUEST
default_product = self.getDefaultProduct() default_product = self.getDefaultProduct()
another_product = self.getDefaultProduct(id = '2')
shipping = self.getDefaultProduct('3')
request.set('session_id', SESSION_ID) request.set('session_id', SESSION_ID)
portal.Resource_addToShoppingCart(default_product, quantity=1)
portal.Resource_addToShoppingCart(another_product, quantity=1)
shopping_cart = portal.SaleOrder_getShoppingCart() shopping_cart = portal.SaleOrder_getShoppingCart()
portal.SaleOrder_editShoppingCart(field_my_shipping_method=shipping.getRelativeUrl())
# increase shopping item number # increase shopping item number
portal.SaleOrder_editShoppingCart((2, 1,)) portal.SaleOrder_editShoppingCart((2, 1,))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment