Commit 4e634d24 authored by Gabriel Monnerat's avatar Gabriel Monnerat

clean up the code and add new test

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42319 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 641242fe
...@@ -27,8 +27,6 @@ ...@@ -27,8 +27,6 @@
############################################################################## ##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from DateTime import DateTime
import transaction
class TestUNG(ERP5TypeTestCase): class TestUNG(ERP5TypeTestCase):
""" """
...@@ -65,25 +63,43 @@ class TestUNG(ERP5TypeTestCase): ...@@ -65,25 +63,43 @@ class TestUNG(ERP5TypeTestCase):
'erp5_web_ung_role', 'erp5_web_ung_role',
'erp5_web_ung_theme') 'erp5_web_ung_theme')
def createDocumentUsingTemplate(self, template): def assertCreateDocumentUsingTemplate(self, template, **kw):
web_page_module = self.portal.web_page_module
self.portal.ERP5Site_createNewWebDocument(template) self.portal.ERP5Site_createNewWebDocument(template)
transaction.commit() self.stepTic()
self.tic() web_page_search = web_page_module.searchFolder(**kw)
self.assertEquals(1, len(web_page_search))
def getTitleListToBySubjectDomain(self):
parent = self.portal.portal_domains.ung_domain.by_subject
return [domain.getTitle() for domain in self.portal.WebPageModule_generateDomain(0, parent)]
def testERP5Site_createNewWebDocument(self): def testERP5Site_createNewWebDocument(self):
""" """
Test if the script creates the objects using Templates correctly Test if the script creates the objects using Templates correctly
XXX - Refactor tests to better validate the creation of objects XXX - Refactor tests to better validate the creation of objects
""" """
self.createDocumentUsingTemplate("web_page_template") web_page_module = self.portal.web_page_module
web_page_search = self.portal.portal_catalog(portal_type="Web Page", self.assertCreateDocumentUsingTemplate("web_page_template",
reference="default-Web.Page.Reference") portal_type="Web Page",
self.assertEquals(2, len(web_page_search)) reference="default-Web.Page.Reference")
self.createDocumentUsingTemplate("web_table_template") self.assertCreateDocumentUsingTemplate("web_table_template",
web_table_search = self.portal.portal_catalog(portal_type="Web Table", portal_type="Web Table",
reference="default-Web.Table.Reference") reference="default-Web.Table.Reference")
self.assertEquals(2, len(web_table_search)) self.assertCreateDocumentUsingTemplate("web_illustration_template",
self.createDocumentUsingTemplate("web_illustration_template") portal_type="Web Illustration",
web_illustration_search = self.portal.portal_catalog(portal_type="Web Illustration", reference="default-Web.Illustration.Reference")
reference="default-Web.Illustration.Reference")
self.assertEquals(2, len(web_illustration_search)) def testWebPageModule_generateDomain(self):
\ No newline at end of file """
Test if script WebPageModule_generateDomain generates the list of domains
correctly
"""
web_page = self.portal.web_page_module.newContent(portal_type="Web Page")
self.stepTic()
title_list = self.getTitleListToBySubjectDomain()
self.assertFalse("Ung" in title_list)
web_page.setSubjectList("Ung")
self.stepTic()
title_list = self.getTitleListToBySubjectDomain()
self.assertTrue("Ung" in title_list, title_list)
\ No newline at end of file
163 164
\ No newline at end of file \ 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