Commit 62f8fb72 authored by Lucas Carvalho's avatar Lucas Carvalho

Added new test for WebSection_getProductList script.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28323 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent daa4b7c3
...@@ -82,9 +82,7 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -82,9 +82,7 @@ class TestCommerce(ERP5TypeTestCase):
Not tested : Not tested :
Person_getApplicableDiscountList Person_getApplicableDiscountList
Person_getApplicableTaxList Person_getApplicableTaxList
SaleOrder_getAvailableShippingResourceList
SaleOrder_externalPaymentHandler SaleOrder_externalPaymentHandler
SaleOrder_finalizeShopping
SaleOrder_getSelectedShippingResource SaleOrder_getSelectedShippingResource
SaleOrder_isShippingRequired SaleOrder_isShippingRequired
SaleOrder_paymentRedirect SaleOrder_paymentRedirect
...@@ -102,11 +100,10 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -102,11 +100,10 @@ class TestCommerce(ERP5TypeTestCase):
Product_getRelatedDescription Product_getRelatedDescription
Person_editPersonalInformation (maybe useless to unittest) Person_editPersonalInformation (maybe useless to unittest)
Resource_getShopUrl Resource_getShopUrl
WebSection_getProductList
""" """
run_all_test = 1 run_all_test = 1
def getTitle(self): def getTitle(self):
return "E-Commerce System" return "E-Commerce System"
...@@ -175,6 +172,8 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -175,6 +172,8 @@ class TestCommerce(ERP5TypeTestCase):
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):
return
person = self.person_module.newContent( person = self.person_module.newContent(
first_name=first_name, first_name=first_name,
last_name=last_name, last_name=last_name,
...@@ -232,6 +231,8 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -232,6 +231,8 @@ class TestCommerce(ERP5TypeTestCase):
category_list = [] category_list = []
portal_categories = portal.portal_categories portal_categories = portal.portal_categories
if hasattr(portal_categories.product_line, 'ldlc'):
portal_categories.product_line.manage_delObjects(['ldlc'])
ldlc = portal_categories.product_line.newContent(portal_type='Category', ldlc = portal_categories.product_line.newContent(portal_type='Category',
id='ldlc', id='ldlc',
title='LDLC') title='LDLC')
...@@ -310,11 +311,11 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -310,11 +311,11 @@ class TestCommerce(ERP5TypeTestCase):
localizer.manage_addLanguage(language=language) localizer.manage_addLanguage(language=language)
# create website # create website
if hasattr(portal.web_site_module, 'web_site'): web_site = getattr(portal.web_site_module, 'web_site', None)
portal.web_site_module.manage_delObjects('web_site') if web_site is None:
web_site = portal.web_site_module.newContent(portal_type = 'Web Site', web_site = portal.web_site_module.newContent(portal_type='Web Site',
id = 'web_site', id='web_site',
**kw) **kw)
transaction.commit() transaction.commit()
self.tic() self.tic()
...@@ -671,11 +672,9 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -671,11 +672,9 @@ class TestCommerce(ERP5TypeTestCase):
ZopeTestCase._print(message) ZopeTestCase._print(message)
LOG('Testing... ', 0, message) LOG('Testing... ', 0, message)
self.createTestUser(first_name="Lucas", self.setupWebSite()
last_name='Carvalho', self.changeUser('webmaster')
reference='lucas',
group=None)
self.changeUser('lucas')
portal = self.getPortal() portal = self.getPortal()
request = self.app.REQUEST request = self.app.REQUEST
request.set('session_id', SESSION_ID) request.set('session_id', SESSION_ID)
...@@ -887,6 +886,33 @@ class TestCommerce(ERP5TypeTestCase): ...@@ -887,6 +886,33 @@ class TestCommerce(ERP5TypeTestCase):
custom_skin.manage_delObjects([method_id]) custom_skin.manage_delObjects([method_id])
self.changeUser('ivan') self.changeUser('ivan')
def test_20_getProductListFromWebSection(self, quiet=0, run=run_all_test):
"""
Test the WebSection_getProductList script.
"""
if not run:
return
if not quiet:
message = '\nTest the script WebSection_getProductList.'
ZopeTestCase._print(message)
LOG('Testing... ', 0, message)
portal = self.getPortal()
web_site = self.setupWebSite()
laptop_product = self.getDefaultProduct(id='1')
laptop_product.setProductLine('ldlc/laptop')
netbook_product = self.getDefaultProduct(id='2')
netbook_product.setProductLine('ldlc/laptop')
web_site.WebSection_generateSectionFromCategory(category='product_line/ldlc',
section_id='products',
depth=2)
transaction.commit()
self.tic()
self.assertEquals(12, len(web_site.products.WebSection_getProductList()))
import unittest import unittest
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
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