Commit c80acc97 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_commerce: Migrate Unit Test.

parent dc7fc5e8
...@@ -210,12 +210,12 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -210,12 +210,12 @@ class TestCommerce(ERP5TypeTestCase):
id='seller') id='seller')
def createTestUser(self, first_name, last_name, reference, group, def createTestUser(self, first_name, last_name, reference, group,
destination_project=None, id=None): destination_project=None):
""" """
Create a user with the given parameters Create a user with the given parameters
""" """
self.person_module = self.getPersonModule() self.person_module = self.getPersonModule()
if hasattr(self.person_module, id or reference): if hasattr(self.person_module, reference):
return return
person = self.person_module.newContent( person = self.person_module.newContent(
first_name=first_name, first_name=first_name,
...@@ -223,7 +223,7 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -223,7 +223,7 @@ class TestCommerce(ERP5TypeTestCase):
reference=reference, reference=reference,
password='secret', password='secret',
career_role='internal', career_role='internal',
id=id or reference, id=reference,
) )
# Set the assignment # Set the assignment
...@@ -240,7 +240,7 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -240,7 +240,7 @@ class TestCommerce(ERP5TypeTestCase):
self.portal.acl_users.zodb_roles.assignRoleToPrincipal('Manager', self.portal.acl_users.zodb_roles.assignRoleToPrincipal('Manager',
person.Person_getUserId()) person.Person_getUserId())
def getDefaultProduct(self, id='1'): def getDefaultProduct(self, id='1'): # pylint: disable=redefined-builtin
""" """
Get default product. Get default product.
""" """
...@@ -308,7 +308,7 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -308,7 +308,7 @@ class TestCommerce(ERP5TypeTestCase):
ups.publish() ups.publish()
self.tic() self.tic()
def createUser(self, name, role_list): def createUser(self, name, role_list): # pylint: disable=arguments-differ
user_folder = self.portal.acl_users user_folder = self.portal.acl_users
user_folder._doAddUser(name, 'password', role_list, []) user_folder._doAddUser(name, 'password', role_list, [])
...@@ -444,7 +444,6 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -444,7 +444,6 @@ class TestCommerce(ERP5TypeTestCase):
self.website.Resource_addToShoppingCart(default_product, 1) self.website.Resource_addToShoppingCart(default_product, 1)
self.website.Resource_addToShoppingCart(another_product, 1) self.website.Resource_addToShoppingCart(another_product, 1)
shopping_cart = self.portal.SaleOrder_getShoppingCart()
self.assertEqual(40.0, \ self.assertEqual(40.0, \
float(self.website.SaleOrder_getShoppingCartTotalPrice())) float(self.website.SaleOrder_getShoppingCartTotalPrice()))
# include taxes (by default it's 20%) # include taxes (by default it's 20%)
...@@ -484,7 +483,6 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -484,7 +483,6 @@ class TestCommerce(ERP5TypeTestCase):
self.website.Resource_addToShoppingCart(default_product, quantity=1) self.website.Resource_addToShoppingCart(default_product, quantity=1)
self.website.Resource_addToShoppingCart(another_product, quantity=1) self.website.Resource_addToShoppingCart(another_product, quantity=1)
shopping_cart = self.portal.SaleOrder_getShoppingCart()
shipping_url = shipping.getRelativeUrl() shipping_url = shipping.getRelativeUrl()
# increase shopping item number and set shipping # increase shopping item number and set shipping
...@@ -523,11 +521,10 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -523,11 +521,10 @@ class TestCommerce(ERP5TypeTestCase):
""" """
Test clear of shopping cart. Test clear of shopping cart.
""" """
default_product = self.getDefaultProduct()
self.createShoppingCartWithProductListAndShipping() self.createShoppingCartWithProductListAndShipping()
self.tic() self.tic()
shopping_cart = self.website.SaleOrder_getShoppingCart(action='reset') self.website.SaleOrder_getShoppingCart(action='reset')
self.assertEqual(0, len(self.website.SaleOrder_getShoppingCartItemList())) self.assertEqual(0, len(self.website.SaleOrder_getShoppingCartItemList()))
def test_07_SessionIDGeneration(self): def test_07_SessionIDGeneration(self):
...@@ -636,7 +633,6 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -636,7 +633,6 @@ class TestCommerce(ERP5TypeTestCase):
""" """
Test the SaleOrder_getAvailableShippingResourceList script Test the SaleOrder_getAvailableShippingResourceList script
""" """
default_product = self.getDefaultProduct()
product_line = self.portal.portal_categories.product_line product_line = self.portal.portal_categories.product_line
shipping_url = product_line.shipping.getRelativeUrl() shipping_url = product_line.shipping.getRelativeUrl()
self.portal.product_module.newContent(portal_type='Product', self.portal.product_module.newContent(portal_type='Product',
...@@ -652,7 +648,7 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -652,7 +648,7 @@ class TestCommerce(ERP5TypeTestCase):
""" """
sale_order = self.portal.sale_order_module.newContent( sale_order = self.portal.sale_order_module.newContent(
portal_type="Sale Order") portal_type="Sale Order")
sale_order_line = sale_order.newContent(portal_type="Sale Order Line", sale_order.newContent(portal_type="Sale Order Line",
quantity="2", quantity="2",
price="10") price="10")
...@@ -811,7 +807,6 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -811,7 +807,6 @@ class TestCommerce(ERP5TypeTestCase):
""" """
default_product = self.getDefaultProduct(id='1') default_product = self.getDefaultProduct(id='1')
self.website.Resource_addToShoppingCart(default_product, 1) self.website.Resource_addToShoppingCart(default_product, 1)
shopping_cart = self.website.SaleOrder_getShoppingCart()
# add shipping # add shipping
shipping = self.getDefaultProduct('3') shipping = self.getDefaultProduct('3')
...@@ -886,7 +881,9 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -886,7 +881,9 @@ class TestCommerce(ERP5TypeTestCase):
Anonymous user must be able to get product image. Anonymous user must be able to get product image.
""" """
product = self.getDefaultProduct() product = self.getDefaultProduct()
file_upload = FileUpload(os.path.join(os.path.dirname(__file__), import Products.ERP5.tests
file_upload = FileUpload(
os.path.join(os.path.dirname(Products.ERP5.tests.__file__),
'test_data', 'images', 'erp5_logo_small.png')) 'test_data', 'images', 'erp5_logo_small.png'))
product.edit(default_image_file=file_upload) product.edit(default_image_file=file_upload)
self.tic() self.tic()
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testERP5Commerce</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Products.ERP5.tests.testERP5Commerce</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testERP5Commerce</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
test.erp5.testERP5Commerce
\ No newline at end of file
erp5_full_text_mroonga_catalog
erp5_core_proxy_field_legacy
erp5_base
erp5_simulation
erp5_configurator_standard_trade_template
erp5_simulation_test
\ No newline at end of file
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