Commit 55cd18ec authored by Łukasz Nowak's avatar Łukasz Nowak

Merge remote-tracking branch 'origin/master' into lazy_simulation_causality

parents 8982ecde b3c18ce8
......@@ -38,5 +38,5 @@ Changes
0.1 (2011-08-08)
----------------
* erp5.util.testnode imported from recipe like slapos.cookbook
* erp5.util.testnode imported from recipe-like slapos.cookbook
[Łukasz Nowak]
......@@ -43,6 +43,7 @@
<key> <string>group_list</string> </key>
<value>
<tuple>
<string>document</string>
<string>my_document</string>
<string>recent_document</string>
<string>web_document</string>
......
......@@ -50,15 +50,19 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if conv_obj_type == \'Web Page\':\n
conv_module_path = \'/erp5/web_page_module\'\n
else:\n
conv_module_path = \'/erp5/test_page_module\'\n
conv_obj_module = context.restrictedTraverse(conv_module_path)\n
<value> <string># XXX (rafael) I beleave KM has a much better way to do this, \n
# clone web page.\n
\n
conv_module_id = \'test_page_module\'\n
\n
if conv_obj_type == \'Web Page\':\n
conv_module_id = \'web_page_module\'\n
\n
conv_obj_module = context.getDefaultModule(conv_obj_type)\n
counter = 0\n
for uid in uids:\n
counter += 1\n
obj = context.portal_catalog(uid=uid)[0]\n
obj = context.portal_catalog.getResultValue(uid=uid)\n
conv_obj = conv_obj_module.newContent(portal_type = conv_obj_type,\n
title = obj.getTitle(),\n
short_title = obj.getShortTitle(),\n
......@@ -72,11 +76,10 @@ for uid in uids:\n
text_content = obj.getTextContent(),\n
format = obj.getFormat(),\n
contributor_list = obj.getContributorList())\n
try:\n
context.restrictedTraverse(conv_module_path)\n
except:\n
conv_obj.setId(obj.getId())\n
conv_obj = conv_obj.manage_pasteObjects(obj.manage_copyObjects(map(lambda x: x.getId(), obj.objectValues())))\n
\n
conv_obj = conv_obj.manage_pasteObjects(\n
obj.manage_copyObjects(\n
map(lambda x: x.getId(), obj.objectValues())))\n
\n
return conv_obj_module.Base_redirect(\'\', dict(portal_status_message=context.Base_translateString(str(counter) + " object(s) converted.")))\n
</string> </value>
......@@ -87,7 +90,7 @@ return conv_obj_module.Base_redirect(\'\', dict(portal_status_message=context.Ba
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TestPageModule_convertPages</string> </value>
<value> <string>TestPageModule_convertPage</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.TestPageModule_convertPages(uids, \'Web Page\')\n
<value> <string>return context.TestPageModule_convertPage(uids, \'Test Page\')\n
</string> </value>
</item>
<item>
......@@ -59,7 +59,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TestPageModule_convertToWebPages</string> </value>
<value> <string>TestPageModule_convertToTestPage</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.TestPageModule_convertPages(uids, \'Test Page\')\n
<value> <string>return context.TestPageModule_convertPage(uids, \'Web Page\')\n
</string> </value>
</item>
<item>
......@@ -59,7 +59,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TestPageModule_convertToTestPages</string> </value>
<value> <string>TestPageModule_convertToWebPage</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
Fetches Web Pages from the Web Page Module\n
"""\n
element_list = context.restrictedTraverse(\'/erp5/web_page_module\').objectValues()\n
\n
for sorted_element in sort_on:\n
element_list = sorted(element_list, key = lambda x: x.getProperty(sorted_element[0]), reverse = sorted_element[1] == \'descending\')\n
\n
return element_list\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>sort_on = [], **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TestPageModule_listWebPages</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -35,7 +35,7 @@
</item>
<item>
<key> <string>action</string> </key>
<value> <string>TestPageModule_convertToTestPages</string> </value>
<value> <string>TestPageModule_convertToTestPage</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
......@@ -15,10 +15,12 @@
<string>count_method</string>
<string>domain_root_list</string>
<string>domain_tree</string>
<string>editable_columns</string>
<string>lines</string>
<string>list_method</string>
<string>portal_types</string>
<string>selection_name</string>
<string>sort</string>
<string>sort_columns</string>
<string>title</string>
</list>
</value>
......@@ -167,10 +169,6 @@
<string>language</string>
<string>Language</string>
</tuple>
<tuple>
<string>int_index</string>
<string>Index</string>
</tuple>
<tuple>
<string>translated_validation_state_title</string>
<string>State</string>
......@@ -197,21 +195,6 @@
<key> <string>domain_tree</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>editable_columns</string> </key>
<value>
<list>
<tuple>
<string>creation_date</string>
<string>Creation Date</string>
</tuple>
<tuple>
<string>modification_date</string>
<string>Modification Date</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_list_mode_listbox</string> </value>
......@@ -230,9 +213,54 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>portal_types</string> </key>
<value>
<list>
<tuple>
<string>Web Page</string>
<string>Web Page</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value> <string>web_page_module_view_web_page_list_selection</string> </value>
<value> <string>test_page_view_web_page_list_selection</string> </value>
</item>
<item>
<key> <string>sort</string> </key>
<value>
<list>
<tuple>
<string>id</string>
<string>ID</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>sort_columns</string> </key>
<value>
<list>
<tuple>
<string>id</string>
<string>ID</string>
</tuple>
<tuple>
<string>reference</string>
<string>Reference</string>
</tuple>
<tuple>
<string>short_title</string>
<string>Short Title</string>
</tuple>
<tuple>
<string>title</string>
<string>Long Title</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>target</string> </key>
......@@ -256,7 +284,7 @@
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>TestPageModule_listWebPages</string> </value>
<value> <string>portal_catalog</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -35,7 +35,7 @@
</item>
<item>
<key> <string>action</string> </key>
<value> <string>TestPageModule_convertToWebPages</string> </value>
<value> <string>TestPageModule_convertToWebPage</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
##############################################################################
#
# Copyright (c) 2002-2012 Nexedi SA and Contributors. All Rights Reserved.
# Rafael Monnerat <rafael@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestRunMyDoc(ERP5TypeTestCase):
"""
Basic Test for internal implementation of RunMyDocs
"""
def getTitle(self):
return "Run My Doc"
def getBusinessTemplateList(self):
"""
Tuple of Business Templates we need to install
"""
# Include all list here.
return ['erp5_base'
'erp5_jquery'
'erp5_jquery_ui'
'erp5_knowledge_pad'
'erp5_web'
'erp5_dms'
'erp5_slideshow_style'
'erp5_ui_test_core',
'erp5_run_my_doc']
def afterSetUp(self):
"""
This is ran before anything, used to set the environment
"""
# here, you can create the categories and objects your test will depend on
pass
website_id = "test_page_web_site"
def test_getDocumentListWithTestPage(self):
"""
Assert if Test Page works with getDocumentList
"""
test_page_reference = "developer-my.test.page"
website = getattr(self.portal.web_site_module, self.website_id, None)
if website is None:
website = self.portal.web_site_module.newContent(
portal_type='Web Site',
id=self.website_id)
website.publish()
self.stepTic()
test_page = self.portal.test_page_module.newContent(
portal_type="Test Page",
reference=test_page_reference,
language="en",
version="001")
test_page.publish()
self.stepTic()
document = website.WebSection_getDocumentValue(test_page_reference)
self.assertNotEquals(None, document)
self.assertEquals(document.getRelativeUrl(),
test_page.getRelativeUrl())
\ No newline at end of file
6
\ No newline at end of file
9
\ No newline at end of file
testRunMyDoc
\ No newline at end of file
......@@ -32,8 +32,6 @@ import re
import unittest
import transaction
from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import getSecurityManager
from Testing import ZopeTestCase
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
......@@ -41,18 +39,19 @@ from Products.ERP5Type.tests.utils import DummyLocalizer
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5Type.tests.backportUnittest import expectedFailure
LANGUAGE_LIST = ('en', 'fr', 'de', 'bg',)
LANGUAGE_LIST = ('en', 'fr', 'de', 'bg', )
HTTP_OK = 200
MOVED_TEMPORARILY = 302
class TestERP5Web(ERP5TypeTestCase):
"""Test for erp5_web business template.
"""
manager_username = 'zope'
manager_password = 'zope'
website_id = 'test'
credential = '%s:%s' % (manager_username, manager_password)
def getTitle(self):
return "ERP5Web"
......@@ -70,12 +69,14 @@ class TestERP5Web(ERP5TypeTestCase):
portal = self.getPortal()
uf = portal.acl_users
uf._doAddUser(self.manager_username, self.manager_password, ['Manager'], [])
uf._doAddUser(self.manager_username,
self.manager_password,
['Manager'], [])
self.login(self.manager_username)
self.web_page_module = self.portal.getDefaultModule('Web Page Module')
self.web_site_module = self.portal.getDefaultModule('Web Site Module')
portal.Localizer.manage_changeDefaultLang(language = 'en')
portal.Localizer.manage_changeDefaultLang(language='en')
self.portal_id = self.portal.getId()
def clearModule(self, module):
......@@ -93,18 +94,17 @@ class TestERP5Web(ERP5TypeTestCase):
Setup Web Site
"""
portal = self.getPortal()
request = self.app.REQUEST
# add supported languages for Localizer
localizer = portal.Localizer
for language in LANGUAGE_LIST:
localizer.manage_addLanguage(language = language)
localizer.manage_addLanguage(language=language)
# create website
if hasattr(self.web_site_module, self.website_id):
self.web_site_module.manage_delObjects(self.website_id)
website = self.getPortal().web_site_module.newContent(portal_type = 'Web Site',
id = self.website_id,
website = self.web_site_module.newContent(portal_type='Web Site',
id=self.website_id,
**kw)
website.publish()
self.stepTic()
......@@ -114,11 +114,10 @@ class TestERP5Web(ERP5TypeTestCase):
"""
Setup Web Section
"""
web_site_module = self.portal.getDefaultModule('Web Site')
website = web_site_module[self.website_id]
website = self.web_site_module[self.website_id]
websection = website.newContent(portal_type='Web Section', **kw)
self.websection = websection
kw = dict(criterion_property_list = 'portal_type',
kw = dict(criterion_property_list='portal_type',
membership_criterion_base_category_list='',
membership_criterion_category_list='')
websection.edit(**kw)
......@@ -136,11 +135,6 @@ class TestERP5Web(ERP5TypeTestCase):
Setup some Web Pages.
"""
webpage_list = []
portal = self.getPortal()
request = self.app.REQUEST
web_site_module = self.portal.getDefaultModule('Web Site')
website = web_site_module[self.website_id]
# create sample web pages
for language in language_list:
if suffix is not None:
......@@ -167,9 +161,7 @@ class TestERP5Web(ERP5TypeTestCase):
Test that a recataloging works for Web Site documents
"""
self.setupWebSite()
portal = self.getPortal()
web_site_module = self.portal.getDefaultModule('Web Site')
web_site = web_site_module[self.website_id]
web_site = self.web_site_module[self.website_id]
self.assertTrue(web_site is not None)
# Recatalog the Web Site document
......@@ -194,7 +186,7 @@ class TestERP5Web(ERP5TypeTestCase):
if it is wrapped by certian column width.
"""
# disable portal_transforms cache
self.portal.portal_transforms.max_sec_in_cache=-1
self.portal.portal_transforms.max_sec_in_cache = -1
page = self.web_page_module.newContent(portal_type='Web Page')
page.edit(text_content='<p>Hé Hé Hé!</p>')
self.stepTic()
......@@ -211,21 +203,22 @@ Hé Hé Hé!""", page.asText().strip())
self.setupWebSite()
portal = self.getPortal()
request = self.app.REQUEST
kw = dict(reference = 'web',
first_name = 'TestFN',
last_name = 'TestLN',
default_email_text = 'test@test.com',
password = 'abc',
password_confirm = 'abc',)
kw = dict(reference='web',
first_name='TestFN',
last_name='TestLN',
default_email_text='test@test.com',
password='abc',
password_confirm='abc',)
for key, item in kw.items():
request.set('field_your_%s' %key, item)
website = portal.web_site_module[self.website_id]
request.set('field_your_%s' % key, item)
website = self.web_site_module[self.website_id]
website.WebSite_createWebSiteAccount('WebSite_viewRegistrationDialog')
self.stepTic()
# find person object by reference
person = website.ERP5Site_getAuthenticatedMemberPersonValue(kw['reference'])
person = website.ERP5Site_getAuthenticatedMemberPersonValue(
kw['reference'])
self.assertEquals(person.getReference(), kw['reference'])
self.assertEquals(person.getFirstName(), kw['first_name'])
self.assertEquals(person.getLastName(), kw['last_name'])
......@@ -234,23 +227,25 @@ Hé Hé Hé!""", page.asText().strip())
# check if user account is 'loggable'
uf = portal.acl_users
user = uf.getUserById( kw['reference'])
user = uf.getUserById(kw['reference'])
self.assertEquals(str(user), kw['reference'])
self.assertEquals(1, user.has_role(('Member', 'Authenticated',)))
self.login(kw['reference'])
self.assertEquals(kw['reference'], str(self.portal.portal_membership.getAuthenticatedMember()))
self.assertEquals(kw['reference'],
str(portal.portal_membership.getAuthenticatedMember()))
# test redirection to person oobject
path = website.absolute_url_path() + '/WebSite_redirectToUserView'
response = self.publish(path, '%s:%s' %(kw['reference'], kw['password']))
response = self.publish(path, '%s:%s' % (kw['reference'], kw['password']))
self.assertTrue(person.getRelativeUrl() in response.getHeader("Location"))
# test redirecting to new Person preference
path = website.absolute_url_path() + '/WebSite_redirectToUserPreference'
response = self.publish(path, '%s:%s' %(kw['reference'], kw['password']))
response = self.publish(path, '%s:%s' % (kw['reference'], kw['password']))
self.assertTrue('portal_preferences' in response.getHeader("Location"))
# one preference should be created for user
self.assertEquals(1, self.portal.portal_catalog.countResults(**{'portal_type': 'Preference',
self.assertEquals(1,
self.portal.portal_catalog.countResults(**{'portal_type': 'Preference',
'owner': kw['reference']})[0][0])
def test_04_WebPageTranslation(self):
......@@ -259,18 +254,17 @@ Hé Hé Hé!""", page.asText().strip())
current user selected language in browser.
"""
portal = self.getPortal()
request = self.app.REQUEST
website = self.setupWebSite()
websection = self.setupWebSection()
page_reference = 'default-webpage'
webpage_list = self.setupWebSitePages(prefix = page_reference)
webpage_list = self.setupWebSitePages(prefix=page_reference)
# set default web page for section
found_by_reference = portal.portal_catalog(name = page_reference,
portal_type = 'Web Page')
found_by_reference = portal.portal_catalog(name=page_reference,
portal_type='Web Page')
found = found_by_reference[0].getObject()
websection.edit(categories_list = ['aggregate/%s' %found.getRelativeUrl(),])
self.assertEqual([found.getReference(),],
websection.edit(categories_list=['aggregate/%s' % found.getRelativeUrl()])
self.assertEqual([found.getReference()],
websection.getAggregateReferenceList())
# even though we create many pages we should get only one
# this is the most recent one since all share the same reference
......@@ -283,14 +277,14 @@ Hé Hé Hé!""", page.asText().strip())
# set default language in Localizer only to check that we get
# the corresponding web page for language.
# XXX: Extend API so we can select language from REQUEST
portal.Localizer.manage_changeDefaultLang(language = language)
portal.Localizer.manage_changeDefaultLang(language=language)
default_document = websection.getDefaultDocumentValue()
self.assertEquals(language, default_document.getLanguage())
def test_05_WebPageTextContentSubstitutions(self):
"""
Simple Case of showing the proper text content with and without a substitution
mapping method.
Simple Case of showing the proper text content with and without a
substitution mapping method.
In case of asText, the content should be replaced too
"""
content = '<a href="${toto}">$titi</a>'
......@@ -318,7 +312,8 @@ Hé Hé Hé!""", page.asText().strip())
klass._getTestSubstitutionMapping = klass.getTestSubstitutionMapping
document.setTextContentSubstitutionMappingMethodId('_getTestSubstitutionMapping')
# Even with the same callable object, a restricted method id should not be callable.
# Even with the same callable object, a restricted method
# id should not be callable.
self.assertRaises(Unauthorized, document.asStrippedHTML)
def test_06_DefaultDocumentForWebSection(self):
......@@ -333,15 +328,15 @@ Hé Hé Hé!""", page.asText().strip())
Note: due to generic ERP5 Web implementation this test highly depends
on WebSection_geDefaulttDocumentValueList
"""
portal = self.getPortal()
website = self.setupWebSite()
websection = self.setupWebSection()
publication_section_category_id_list = ['documentation', 'administration']
# create pages belonging to this publication_section 'documentation'
web_page_en = portal.web_page_module.newContent(portal_type = 'Web Page',
web_page_en = self.web_page_module.newContent(
portal_type='Web Page',
id='section_home',
language = 'en',
language='en',
reference='NXD-DDP',
publication_section_list=publication_section_category_id_list[:1])
websection.setAggregateValue(web_page_en)
......@@ -357,7 +352,8 @@ Hé Hé Hé!""", page.asText().strip())
from Products.ERP5.Document.Document import Document
base_list = re.findall(Document.base_parser, str(html_page))
base_url = base_list[0]
self.assertEqual(base_url, "%s/%s/" % (websection.absolute_url(), web_page_en.getReference()))
self.assertEqual(base_url, "%s/%s/" % (websection.absolute_url(),
web_page_en.getReference()))
def test_06b_DefaultDocumentForWebSite(self):
"""
......@@ -371,12 +367,11 @@ Hé Hé Hé!""", page.asText().strip())
Note: due to generic ERP5 Web implementation this test highly depends
on WebSection_geDefaulttDocumentValueList
"""
portal = self.getPortal()
website = self.setupWebSite()
publication_section_category_id_list = ['documentation', 'administration']
# create pages belonging to this publication_section 'documentation'
web_page_en = portal.web_page_module.newContent(portal_type = 'Web Page',
web_page_en = self.web_page_module.newContent(portal_type = 'Web Page',
id='site_home',
language = 'en',
reference='NXD-DDP-Site',
......@@ -417,31 +412,31 @@ Hé Hé Hé!""", page.asText().strip())
portal.portal_categories.publication_section.newContent(portal_type = 'Category',
id = category_id)
property_dict = { '01' : dict(language = 'en' , version = "1" , reference = "A"),
'02' : dict(language = 'en' , version = "2" , reference = "B"),
'03' : dict(language = 'en' , version = "3" , reference = "C"),
'04' : dict(language = 'pt' , version = "1" , reference = "A"),
'05' : dict(language = 'pt' , version = "2" , reference = "C"),
'06' : dict(language = 'pt' , version = "3" , reference = "B"),
'07' : dict(language = 'ja' , version = "1" , reference = "C"),
'08' : dict(language = 'ja' , version = "2" , reference = "A"),
'09' : dict(language = 'ja' , version = "3" , reference = "B"),
'10' : dict(language = 'en' , version = "2" , reference = "D"),
'11' : dict(language = 'ja' , version = "3" , reference = "E"),
'12' : dict(language = 'pt' , version = "3" , reference = "F"),
'13' : dict(language = 'en' , version = "3" , reference = "D"),
'14' : dict(language = 'ja' , version = "2" , reference = "E"),
'15' : dict(language = 'pt' , version = "2" , reference = "F"),
'16' : dict(language = '' , version = "1" , reference = "A"),
property_dict = {'01': dict(language='en', version="1", reference="A"),
'02': dict(language='en', version="2", reference="B"),
'03': dict(language='en', version="3", reference="C"),
'04': dict(language='pt', version="1", reference="A"),
'05': dict(language='pt', version="2", reference="C"),
'06': dict(language='pt', version="3", reference="B"),
'07': dict(language='ja', version="1", reference="C"),
'08': dict(language='ja', version="2", reference="A"),
'09': dict(language='ja', version="3", reference="B"),
'10': dict(language='en', version="2", reference="D"),
'11': dict(language='ja', version="3", reference="E"),
'12': dict(language='pt', version="3", reference="F"),
'13': dict(language='en', version="3", reference="D"),
'14': dict(language='ja', version="2", reference="E"),
'15': dict(language='pt', version="2", reference="F"),
'16': dict(language='', version="1", reference="A"),
}
sequence_one = property_dict.keys()
sequence_two = ['01', '13', '12', '09', '06', '15' , '04', '11', '02', '05', '03',
'07', '10', '08', '14', '16']
sequence_three = ['05', '12', '13', '14', '06', '09', '10', '07', '03', '01', '02',
'11', '04', '08' , '15', '16']
sequence_two = ['01', '13', '12', '09', '06', '15', '04', '11', '02',
'05', '03', '07', '10', '08', '14', '16']
sequence_three = ['05', '12', '13', '14', '06', '09', '10', '07',
'03', '01', '02', '11', '04', '08', '15', '16']
sequence_count = 0
for sequence in [ sequence_one , sequence_two , sequence_three ]:
for sequence in [sequence_one, sequence_two, sequence_three]:
sequence_count += 1
message = '\ntest_07_WebSection_getDocumentValueList (Sequence %s)' \
% (sequence_count)
......@@ -449,7 +444,7 @@ Hé Hé Hé!""", page.asText().strip())
web_page_list = []
for key in sequence:
web_page = self.portal.web_page_module.newContent(
web_page = self.web_page_module.newContent(
title=key,
portal_type = 'Web Page',
publication_section_list=publication_section_category_id_list[:1])
......@@ -472,105 +467,105 @@ Hé Hé Hé!""", page.asText().strip())
# Testing for language parameter
self.assertEqual(4, len(websection.getDocumentValueList()))
self.assertEqual(['en' , 'en', 'en', 'en'],
[ w.getLanguage() for w in websection.getDocumentValueList()])
self.assertEqual(['en', 'en', 'en', 'en'],
[w.getLanguage() for w in websection.getDocumentValueList()])
# Check that receiving an empty string as language parameter (as done
# when using listbox search) correctly returns user language documents.
default_document_value_list = websection.getDocumentValueList(language='')
self.assertEqual(4, len(default_document_value_list))
self.assertEqual(['en', 'en', 'en', 'en'],
[ w.getLanguage() for w in default_document_value_list])
[w.getLanguage() for w in default_document_value_list])
pt_document_value_list = websection.getDocumentValueList(language='pt')
self.assertEqual(4, len(pt_document_value_list))
self.assertEqual(['pt' , 'pt', 'pt', 'pt'],
[ w.getObject().getLanguage() for w in pt_document_value_list])
self.assertEqual(['pt', 'pt', 'pt', 'pt'],
[w.getObject().getLanguage() for w in pt_document_value_list])
ja_document_value_list = websection.getDocumentValueList(language='ja')
self.assertEqual(4, len(ja_document_value_list))
self.assertEqual(['ja' , 'ja', 'ja', 'ja'],
[ w.getLanguage() for w in ja_document_value_list])
self.assertEqual(['ja', 'ja', 'ja', 'ja'],
[w.getLanguage() for w in ja_document_value_list])
bg_document_value_list = websection.getDocumentValueList(language='bg')
self.assertEqual(1, len(bg_document_value_list))
self.assertEqual([''],
[ w.getLanguage() for w in bg_document_value_list])
[w.getLanguage() for w in bg_document_value_list])
# Testing for all_versions parameter
en_document_value_list = websection.getDocumentValueList(all_versions=1)
self.assertEqual(5, len(en_document_value_list))
self.assertEqual(['en' , 'en', 'en', 'en', 'en'],
[ w.getLanguage() for w in en_document_value_list])
self.assertEqual(['en', 'en', 'en', 'en', 'en'],
[w.getLanguage() for w in en_document_value_list])
pt_document_value_list = websection.getDocumentValueList(language='pt',
all_versions=1)
self.assertEqual(5, len(pt_document_value_list))
self.assertEqual(['pt' , 'pt', 'pt', 'pt', 'pt'],
[ w.getObject().getLanguage() for w in pt_document_value_list])
self.assertEqual(['pt', 'pt', 'pt', 'pt', 'pt'],
[w.getObject().getLanguage() for w in pt_document_value_list])
ja_document_value_list = websection.getDocumentValueList(language='ja',
all_versions=1)
self.assertEqual(5, len(ja_document_value_list))
self.assertEqual(['ja' , 'ja', 'ja', 'ja', 'ja'],
[ w.getLanguage() for w in ja_document_value_list])
self.assertEqual(['ja', 'ja', 'ja', 'ja', 'ja'],
[w.getLanguage() for w in ja_document_value_list])
# Tests for all_languages parameter
en_document_value_list = websection.WebSection_getDocumentValueListBase(all_languages=1)
self.assertEqual(6, len(en_document_value_list))
self.assertEqual(4, len([ w.getLanguage() for w in en_document_value_list \
self.assertEqual(4, len([w.getLanguage() for w in en_document_value_list \
if w.getLanguage() == 'en']))
self.assertEqual(1, len([ w.getLanguage() for w in en_document_value_list \
self.assertEqual(1, len([w.getLanguage() for w in en_document_value_list \
if w.getLanguage() == 'pt']))
self.assertEqual(['3'], [ w.getVersion() for w in en_document_value_list \
self.assertEqual(['3'], [w.getVersion() for w in en_document_value_list \
if w.getLanguage() == 'pt'])
self.assertEqual(1, len([ w.getLanguage() for w in en_document_value_list \
self.assertEqual(1, len([w.getLanguage() for w in en_document_value_list \
if w.getLanguage() == 'ja']))
self.assertEqual(['3'], [ w.getVersion() for w in en_document_value_list \
self.assertEqual(['3'], [w.getVersion() for w in en_document_value_list \
if w.getLanguage() == 'ja'])
pt_document_value_list = websection.WebSection_getDocumentValueListBase(all_languages=1,
language='pt')
self.assertEqual(6, len(pt_document_value_list))
self.assertEqual(4, len([ w.getLanguage() for w in pt_document_value_list \
self.assertEqual(4, len([w.getLanguage() for w in pt_document_value_list \
if w.getLanguage() == 'pt']))
self.assertEqual(1, len([ w.getLanguage() for w in pt_document_value_list \
self.assertEqual(1, len([w.getLanguage() for w in pt_document_value_list \
if w.getLanguage() == 'en']))
self.assertEqual(['3'], [ w.getVersion() for w in pt_document_value_list \
self.assertEqual(['3'], [w.getVersion() for w in pt_document_value_list \
if w.getLanguage() == 'en'])
self.assertEqual(1, len([ w.getLanguage() for w in pt_document_value_list \
self.assertEqual(1, len([w.getLanguage() for w in pt_document_value_list \
if w.getLanguage() == 'ja']))
self.assertEqual(['3'], [ w.getVersion() for w in pt_document_value_list \
self.assertEqual(['3'], [w.getVersion() for w in pt_document_value_list \
if w.getLanguage() == 'ja'])
ja_document_value_list = websection.WebSection_getDocumentValueListBase(all_languages=1,
language='ja')
self.assertEqual(6, len(ja_document_value_list))
self.assertEqual(4, len([ w.getLanguage() for w in ja_document_value_list \
self.assertEqual(4, len([w.getLanguage() for w in ja_document_value_list \
if w.getLanguage() == 'ja']))
self.assertEqual(1, len([ w.getLanguage() for w in ja_document_value_list \
self.assertEqual(1, len([w.getLanguage() for w in ja_document_value_list \
if w.getLanguage() == 'pt']))
self.assertEqual(['3'], [ w.getVersion() for w in ja_document_value_list \
self.assertEqual(['3'], [w.getVersion() for w in ja_document_value_list \
if w.getLanguage() == 'pt'])
self.assertEqual(1, len([ w.getLanguage() for w in ja_document_value_list \
self.assertEqual(1, len([w.getLanguage() for w in ja_document_value_list \
if w.getLanguage() == 'en']))
self.assertEqual(['3'], [ w.getVersion() for w in ja_document_value_list \
self.assertEqual(['3'], [w.getVersion() for w in ja_document_value_list \
if w.getLanguage() == 'en'])
bg_document_value_list = websection.WebSection_getDocumentValueListBase(all_languages=1,
language='bg')
self.assertEqual(6, len(bg_document_value_list))
self.assertEqual(0, len([ w.getLanguage() for w in bg_document_value_list \
self.assertEqual(0, len([w.getLanguage() for w in bg_document_value_list \
if w.getLanguage() == 'bg']))
self.assertEqual(3, len([ w.getLanguage() for w in bg_document_value_list \
self.assertEqual(3, len([w.getLanguage() for w in bg_document_value_list \
if w.getLanguage() == 'en']))
self.assertEqual(1, len([ w.getLanguage() for w in bg_document_value_list \
self.assertEqual(1, len([w.getLanguage() for w in bg_document_value_list \
if w.getLanguage() == 'pt']))
self.assertEqual(['3'], [ w.getVersion() for w in bg_document_value_list \
self.assertEqual(['3'], [w.getVersion() for w in bg_document_value_list \
if w.getLanguage() == 'pt'])
self.assertEqual(1, len([ w.getLanguage() for w in bg_document_value_list \
self.assertEqual(1, len([w.getLanguage() for w in bg_document_value_list \
if w.getLanguage() == 'ja']))
self.assertEqual(['3'], [ w.getVersion() for w in bg_document_value_list \
self.assertEqual(['3'], [w.getVersion() for w in bg_document_value_list \
if w.getLanguage() == 'ja'])
# Tests for all_languages and all_versions
......@@ -585,51 +580,51 @@ Hé Hé Hé!""", page.asText().strip())
all_versions=1,
language='ja')
for document_value_list in [ en_document_value_list, pt_document_value_list ,
for document_value_list in [en_document_value_list, pt_document_value_list,
ja_document_value_list]:
self.assertEqual(16, len(document_value_list))
self.assertEqual(5, len([ w.getLanguage() for w in document_value_list \
self.assertEqual(5, len([w.getLanguage() for w in document_value_list \
if w.getLanguage() == 'en']))
self.assertEqual(5, len([ w.getLanguage() for w in en_document_value_list \
self.assertEqual(5, len([w.getLanguage() for w in en_document_value_list \
if w.getLanguage() == 'pt']))
self.assertEqual(5, len([ w.getLanguage() for w in en_document_value_list \
self.assertEqual(5, len([w.getLanguage() for w in en_document_value_list \
if w.getLanguage() == 'ja']))
# Tests for sort_on parameter
self.assertEqual(['A' , 'B', 'C', 'D'],
[ w.getReference() for w in \
self.assertEqual(['A', 'B', 'C', 'D'],
[w.getReference() for w in \
websection.getDocumentValueList(sort_on=[('reference', 'ASC')])])
self.assertEqual(['01' , '02', '03', '13'],
[ w.getTitle() for w in \
self.assertEqual(['01', '02', '03', '13'],
[w.getTitle() for w in \
websection.getDocumentValueList(sort_on=[('title', 'ASC')])])
self.assertEqual(['D' , 'C', 'B', 'A'],
[ w.getReference() for w in \
self.assertEqual(['D', 'C', 'B', 'A'],
[w.getReference() for w in \
websection.getDocumentValueList(sort_on=[('reference', 'DESC')])])
self.assertEqual(['13' , '03', '02', '01'],
[ w.getTitle() for w in \
self.assertEqual(['13', '03', '02', '01'],
[w.getTitle() for w in \
websection.getDocumentValueList(sort_on=[('reference', 'DESC')])])
self.assertEqual(['A' , 'B', 'C', 'D' , 'E' , 'F'],
[ w.getReference() for w in \
self.assertEqual(['A', 'B', 'C', 'D', 'E', 'F'],
[w.getReference() for w in \
websection.WebSection_getDocumentValueListBase(all_languages=1,
sort_on=[('reference', 'ASC')])])
self.assertEqual(['01' , '02', '03', '11' , '12' , '13'],
[ w.getTitle() for w in \
self.assertEqual(['01', '02', '03', '11', '12', '13'],
[w.getTitle() for w in \
websection.WebSection_getDocumentValueListBase(all_languages=1,
sort_on=[('title', 'ASC')])])
self.assertEqual(['F' , 'E', 'D', 'C' , 'B' , 'A'],
[ w.getReference() for w in \
self.assertEqual(['F', 'E', 'D', 'C', 'B', 'A'],
[w.getReference() for w in \
websection.WebSection_getDocumentValueListBase(all_languages=1,
sort_on=[('reference', 'DESC')])])
self.assertEqual(['13' , '12', '11', '03' , '02' , '01'],
[ w.getTitle() for w in \
self.assertEqual(['13', '12', '11', '03', '02', '01'],
[w.getTitle() for w in \
websection.WebSection_getDocumentValueListBase(all_languages=1,
sort_on=[('title', 'DESC')])])
......@@ -756,14 +751,12 @@ Hé Hé Hé!""", page.asText().strip())
web_page_portal_type = 'Web Page'
# Create web site and web section
web_site_module = portal.getDefaultModule(web_site_portal_type)
web_site = web_site_module.newContent(portal_type=web_site_portal_type)
web_site = self.web_site_module.newContent(portal_type=web_site_portal_type)
web_section = web_site.newContent(portal_type=web_section_portal_type)
sub_web_section = web_section.newContent(portal_type=web_section_portal_type)
# Create a document
web_page_module = portal.getDefaultModule(web_page_portal_type)
web_page = web_page_module.newContent(portal_type=web_page_portal_type)
web_page = self.web_page_module.newContent(portal_type=web_page_portal_type)
# Commit transaction
def _commit():
......@@ -933,7 +926,6 @@ Hé Hé Hé!""", page.asText().strip())
response = self.publish(path, self.credential)
self.assertNotEquals(response.getBody().find(new_content), -1)
def test_13a_DocumentMovedCache(self):
"""
What happens to the cache if document is moved
......@@ -1040,7 +1032,6 @@ Hé Hé Hé!""", page.asText().strip())
response = self.publish(path, self.credential)
self.assertNotEquals(response.getBody().find(new_content), -1)
def test_14_AccessWebSiteForWithDifferentUserPreferences(self):
"""Check that Ram Cache Manager do not mix websection
rendering between users.
......@@ -1121,7 +1112,6 @@ Hé Hé Hé!""", page.asText().strip())
Policy ID - unauthenticated web pages
authenticated
"""
request = self.portal.REQUEST
website = self.setupWebSite()
web_section_portal_type = 'Web Section'
web_section = website.newContent(portal_type=web_section_portal_type)
......@@ -1185,9 +1175,6 @@ Hé Hé Hé!""", page.asText().strip())
- Access it using another language and edit it
- Check that web section is correctly indexed
"""
portal = self.getPortal()
request = self.app.REQUEST
language = 'de'
website = self.setupWebSite()
......@@ -1244,9 +1231,6 @@ Hé Hé Hé!""", page.asText().strip())
- Access it using another language and edit it
- Check that web site is correctly modified
"""
portal = self.getPortal()
request = self.app.REQUEST
language = 'de'
website = self.setupWebSite()
......@@ -1296,7 +1280,6 @@ Hé Hé Hé!""", page.asText().strip())
"""
Check if isWebMode & isEditableMode API works.
"""
portal = self.getPortal()
request = self.app.REQUEST
website = self.setupWebSite()
......@@ -1326,19 +1309,18 @@ Hé Hé Hé!""", page.asText().strip())
"""
Test Web Site map script.
"""
portal = self.getPortal()
request = self.app.REQUEST
website = self.setupWebSite()
kw = {'depth': 5,
'include_subsection':1}
'include_subsection': 1}
website.setSiteMapSectionParent(1)
websection1 = website.newContent(portal_type='Web Section',
title = 'Section 1',
title='Section 1',
site_map_section_parent=1,
visible=1)
websection1_1 = websection1.newContent(portal_type='Web Section',
title = 'Section 1.1',
title='Section 1.1',
site_map_section_parent=1,
visible=1)
self.stepTic()
......@@ -1356,7 +1338,6 @@ Hé Hé Hé!""", page.asText().strip())
self.assertSameSet([websection1.getTitle()],
[x['translated_title'] for x in site_map])
# hide subsections
websection1_1.setSiteMapSectionParent(0)
websection1_1.setVisible(0)
......@@ -1502,8 +1483,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def test_03_WebSection_getDocumentValueListSecurity(self):
""" Test WebSection_getDocumentValueList behaviour and security"""
self.login('admin')
web_site_module = self.portal.web_site_module
site = web_site_module.newContent(portal_type='Web Site',
site = self.web_site_module.newContent(portal_type='Web Site',
id='site')
site.publish()
......@@ -1639,8 +1619,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def test_04_ExpireUserAction(self):
""" Test the expire user action"""
self.login('admin')
web_site_module = self.portal.web_site_module
site = web_site_module.newContent(portal_type='Web Site', id='site')
site = self.web_site_module.newContent(portal_type='Web Site', id='site')
# create websections in a site and in anothers web sections
section_1 = site.newContent(portal_type='Web Section', id='section_1')
......@@ -1670,7 +1649,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def test_05_createWebSite(self):
""" Test to create or clone web sites with many users """
self.login('admin')
web_site_module = self.portal.web_site_module
web_site_module = self.web_site_module
# test for admin
try:
......@@ -1693,8 +1672,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def test_06_createWebSection(self):
""" Test to create or clone web sections with many users """
self.login('admin')
web_site_module = self.portal.web_site_module
site = web_site_module.newContent(portal_type='Web Site', id='site')
site = self.web_site_module.newContent(portal_type='Web Site', id='site')
# test for admin
try:
......@@ -1806,7 +1784,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
pass
try:
new_category_3 = publication_section.newContent(
portal_type='Category',id='new_category_3')
portal_type='Category', id='new_category_3')
new_category_4 = new_category_3.newContent(portal_type='Category',
id='new_category_4')
except Unauthorized:
......@@ -1839,7 +1817,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
project.validate()
self.stepTic()
website = self.portal.web_site_module.newContent(portal_type='Web Site',
website = self.web_site_module.newContent(portal_type='Web Site',
id='site')
website.publish()
website.setMembershipCriterionBaseCategory('follow_up')
......@@ -1876,9 +1854,8 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
"""
Test that by default Anonymous User cannot access Web Site Module
"""
portal = self.portal
self.logout()
self.assertRaises(Unauthorized, portal.web_site_module.view)
self.assertRaises(Unauthorized, self.web_site_module.view)
class TestERP5WebCategoryPublicationWorkflow(ERP5TypeTestCase):
......@@ -1911,6 +1888,7 @@ class TestERP5WebCategoryPublicationWorkflow(ERP5TypeTestCase):
self.doActionFor(self.category, 'expire_action')
self.assertEqual('expired_published', self.category.getValidationState())
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Web))
......
......@@ -63,9 +63,12 @@ setup(name=name,
entry_points={
'console_scripts': [
'testnode = erp5.util.testnode:main [testnode]',
'performance_tester_erp5 = erp5.util.benchmark.performance_tester:main [benchmark]',
'scalability_tester_erp5 = erp5.util.benchmark.scalability_tester:main [scalability_tester]',
'generate_erp5_tester_report = erp5.util.benchmark.report:generateReport [benchmark-report]',
'performance_tester_erp5 = '\
'erp5.util.benchmark.performance_tester:main [benchmark]',
'scalability_tester_erp5 = '\
'erp5.util.benchmark.scalability_tester:main [scalability_tester]',
'generate_erp5_tester_report = '\
'erp5.util.benchmark.report:generateReport [benchmark-report]',
'web_checker_utility = erp5.util.webchecker:web_checker_utility'
],
}
......
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