Commit c80acc97 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: erp5_commerce: Migrate Unit Test.

parent dc7fc5e8
......@@ -204,18 +204,18 @@ class TestCommerce(ERP5TypeTestCase):
"""
self.organisation_module = self.portal.getDefaultModule('Organisation')
if 'seller' not in self.organisation_module.objectIds():
self.nexedi = self.organisation_module.newContent(title="Seller",
self.nexedi = self.organisation_module.newContent(title="Seller",
group='seller',
role='internal',
id='seller')
def createTestUser(self, first_name, last_name, reference, group,
destination_project=None, id=None):
destination_project=None):
"""
Create a user with the given parameters
"""
self.person_module = self.getPersonModule()
if hasattr(self.person_module, id or reference):
if hasattr(self.person_module, reference):
return
person = self.person_module.newContent(
first_name=first_name,
......@@ -223,7 +223,7 @@ class TestCommerce(ERP5TypeTestCase):
reference=reference,
password='secret',
career_role='internal',
id=id or reference,
id=reference,
)
# Set the assignment
......@@ -240,7 +240,7 @@ class TestCommerce(ERP5TypeTestCase):
self.portal.acl_users.zodb_roles.assignRoleToPrincipal('Manager',
person.Person_getUserId())
def getDefaultProduct(self, id='1'):
def getDefaultProduct(self, id='1'): # pylint: disable=redefined-builtin
"""
Get default product.
"""
......@@ -308,7 +308,7 @@ class TestCommerce(ERP5TypeTestCase):
ups.publish()
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._doAddUser(name, 'password', role_list, [])
......@@ -444,7 +444,6 @@ class TestCommerce(ERP5TypeTestCase):
self.website.Resource_addToShoppingCart(default_product, 1)
self.website.Resource_addToShoppingCart(another_product, 1)
shopping_cart = self.portal.SaleOrder_getShoppingCart()
self.assertEqual(40.0, \
float(self.website.SaleOrder_getShoppingCartTotalPrice()))
# include taxes (by default it's 20%)
......@@ -484,7 +483,6 @@ class TestCommerce(ERP5TypeTestCase):
self.website.Resource_addToShoppingCart(default_product, quantity=1)
self.website.Resource_addToShoppingCart(another_product, quantity=1)
shopping_cart = self.portal.SaleOrder_getShoppingCart()
shipping_url = shipping.getRelativeUrl()
# increase shopping item number and set shipping
......@@ -523,11 +521,10 @@ class TestCommerce(ERP5TypeTestCase):
"""
Test clear of shopping cart.
"""
default_product = self.getDefaultProduct()
self.createShoppingCartWithProductListAndShipping()
self.tic()
shopping_cart = self.website.SaleOrder_getShoppingCart(action='reset')
self.website.SaleOrder_getShoppingCart(action='reset')
self.assertEqual(0, len(self.website.SaleOrder_getShoppingCartItemList()))
def test_07_SessionIDGeneration(self):
......@@ -636,7 +633,6 @@ class TestCommerce(ERP5TypeTestCase):
"""
Test the SaleOrder_getAvailableShippingResourceList script
"""
default_product = self.getDefaultProduct()
product_line = self.portal.portal_categories.product_line
shipping_url = product_line.shipping.getRelativeUrl()
self.portal.product_module.newContent(portal_type='Product',
......@@ -652,9 +648,9 @@ class TestCommerce(ERP5TypeTestCase):
"""
sale_order = self.portal.sale_order_module.newContent(
portal_type="Sale Order")
sale_order_line = sale_order.newContent(portal_type="Sale Order Line",
quantity="2",
price="10")
sale_order.newContent(portal_type="Sale Order Line",
quantity="2",
price="10")
self.assertEqual(
sale_order.getCreationDate().strftime('%a, %d %b %Y %H:%M %p'),
......@@ -811,7 +807,6 @@ class TestCommerce(ERP5TypeTestCase):
"""
default_product = self.getDefaultProduct(id='1')
self.website.Resource_addToShoppingCart(default_product, 1)
shopping_cart = self.website.SaleOrder_getShoppingCart()
# add shipping
shipping = self.getDefaultProduct('3')
......@@ -886,8 +881,10 @@ class TestCommerce(ERP5TypeTestCase):
Anonymous user must be able to get product image.
"""
product = self.getDefaultProduct()
file_upload = FileUpload(os.path.join(os.path.dirname(__file__),
'test_data', 'images', 'erp5_logo_small.png'))
import Products.ERP5.tests
file_upload = FileUpload(
os.path.join(os.path.dirname(Products.ERP5.tests.__file__),
'test_data', 'images', 'erp5_logo_small.png'))
product.edit(default_image_file=file_upload)
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