Commit e66d7a6f authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

cleanup (i.e. fix typos, remove needless white spaces, needless imports etc.).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28939 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent efb199b8
############################################################################## ##############################################################################
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (c) 2004, 2005, 2006 Nexedi SARL and Contributors. # Copyright (c) 2004, 2005, 2006 Nexedi SARL and Contributors.
# All Rights Reserved. # All Rights Reserved.
# Romain Courteaud <romain@nexedi.com> # Romain Courteaud <romain@nexedi.com>
# #
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial # End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software # guarantees and support are strongly adviced to contract a Free Software
# Service Company # Service Company
# #
# This program is Free Software; you can redistribute it and/or # This program is Free Software; you can redistribute it and/or
...@@ -28,10 +28,8 @@ ...@@ -28,10 +28,8 @@
# #
############################################################################## ##############################################################################
import os
import re import re
import unittest import unittest
import random
import transaction import transaction
from AccessControl import Unauthorized from AccessControl import Unauthorized
...@@ -53,7 +51,6 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -53,7 +51,6 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
manager_password = 'zope' manager_password = 'zope'
website_id = 'test' website_id = 'test'
def getTitle(self): def getTitle(self):
return "ERP5Web" return "ERP5Web"
...@@ -95,22 +92,22 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -95,22 +92,22 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
""" """
portal = self.getPortal() portal = self.getPortal()
request = self.app.REQUEST request = self.app.REQUEST
# add supported languages for Localizer # add supported languages for Localizer
localizer = portal.Localizer localizer = portal.Localizer
for language in LANGUAGE_LIST: for language in LANGUAGE_LIST:
localizer.manage_addLanguage(language = language) localizer.manage_addLanguage(language = language)
# create website # create website
if hasattr(self.web_site_module, self.website_id): if hasattr(self.web_site_module, self.website_id):
self.web_site_module.manage_delObjects(self.website_id) self.web_site_module.manage_delObjects(self.website_id)
website = self.getPortal().web_site_module.newContent(portal_type = 'Web Site', website = self.getPortal().web_site_module.newContent(portal_type = 'Web Site',
id = self.website_id, id = self.website_id,
**kw) **kw)
transaction.commit() transaction.commit()
self.tic() self.tic()
return website return website
def setupWebSection(self, **kw): def setupWebSection(self, **kw):
""" """
Setup Web Section Setup Web Section
...@@ -125,15 +122,14 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -125,15 +122,14 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
websection.edit(**kw) websection.edit(**kw)
websection.setCriterion(property='portal_type', websection.setCriterion(property='portal_type',
identity=['Web Page'], identity=['Web Page'],
max='', max='',
min='') min='')
transaction.commit() transaction.commit()
self.tic() self.tic()
return websection return websection
def setupWebSitePages(self, prefix, suffix=None, version='0.1', def setupWebSitePages(self, prefix, suffix=None, version='0.1',
language_list=LANGUAGE_LIST, **kw): language_list=LANGUAGE_LIST, **kw):
""" """
Setup some Web Pages. Setup some Web Pages.
...@@ -143,14 +139,14 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -143,14 +139,14 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
request = self.app.REQUEST request = self.app.REQUEST
web_site_module = self.portal.getDefaultModule('Web Site') web_site_module = self.portal.getDefaultModule('Web Site')
website = web_site_module[self.website_id] website = web_site_module[self.website_id]
# create sample web pages # create sample web pages
for language in language_list: for language in language_list:
if suffix is not None: if suffix is not None:
reference = '%s-%s' % (prefix, language) reference = '%s-%s' % (prefix, language)
else: else:
reference = prefix reference = prefix
webpage = self.web_page_module.newContent(portal_type='Web Page', webpage = self.web_page_module.newContent(portal_type='Web Page',
reference=reference, reference=reference,
version=version, version=version,
language=language, language=language,
...@@ -163,9 +159,9 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -163,9 +159,9 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEquals(version, webpage.getVersion()) self.assertEquals(version, webpage.getVersion())
self.assertEquals('published', webpage.getValidationState()) self.assertEquals('published', webpage.getValidationState())
webpage_list.append(webpage) webpage_list.append(webpage)
return webpage_list return webpage_list
def test_01_WebSiteRecatalog(self, quiet=quiet, run=run_all_test): def test_01_WebSiteRecatalog(self, quiet=quiet, run=run_all_test):
""" """
Test that a recataloging works for Web Site documents Test that a recataloging works for Web Site documents
...@@ -174,7 +170,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -174,7 +170,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
if not quiet: if not quiet:
message = '\ntest_01_WebSiteRecatalog' message = '\ntest_01_WebSiteRecatalog'
ZopeTestCase._print(message) ZopeTestCase._print(message)
self.setupWebSite() self.setupWebSite()
portal = self.getPortal() portal = self.getPortal()
web_site_module = self.portal.getDefaultModule('Web Site') web_site_module = self.portal.getDefaultModule('Web Site')
...@@ -188,7 +184,6 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -188,7 +184,6 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
except: except:
self.fail('Cataloging of the Web Site failed.') self.fail('Cataloging of the Web Site failed.')
def test_02_EditSimpleWebPage(self, quiet=quiet, run=run_all_test): def test_02_EditSimpleWebPage(self, quiet=quiet, run=run_all_test):
""" """
Simple Case of creating a web page. Simple Case of creating a web page.
...@@ -201,7 +196,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -201,7 +196,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
page.edit(text_content='<b>OK</b>') page.edit(text_content='<b>OK</b>')
self.assertEquals('text/html', page.getTextFormat()) self.assertEquals('text/html', page.getTextFormat())
self.assertEquals('<b>OK</b>', page.getTextContent()) self.assertEquals('<b>OK</b>', page.getTextContent())
def test_03_CreateWebSiteUser(self, quiet=quiet, run=run_all_test): def test_03_CreateWebSiteUser(self, quiet=quiet, run=run_all_test):
""" """
Create Web site User. Create Web site User.
...@@ -223,10 +218,10 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -223,10 +218,10 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
request.set('field_your_%s' %key, item) request.set('field_your_%s' %key, item)
website = portal.web_site_module[self.website_id] website = portal.web_site_module[self.website_id]
website.WebSite_createWebSiteAccount('WebSite_viewRegistrationDialog') website.WebSite_createWebSiteAccount('WebSite_viewRegistrationDialog')
transaction.commit() transaction.commit()
self.tic() self.tic()
# find person object by reference # 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.getReference(), kw['reference'])
...@@ -235,15 +230,15 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -235,15 +230,15 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEquals(person.getDefaultEmailText(), kw['default_email_text']) self.assertEquals(person.getDefaultEmailText(), kw['default_email_text'])
self.assertEquals(person.getValidationState(), 'validated') self.assertEquals(person.getValidationState(), 'validated')
# check if user account is 'loggable' # check if user account is 'loggable'
uf = portal.acl_users uf = portal.acl_users
user = uf.getUserById( kw['reference']) user = uf.getUserById( kw['reference'])
self.assertEquals(str(user), kw['reference']) self.assertEquals(str(user), kw['reference'])
self.assertEquals(1, user.has_role(('Member', 'Authenticated',))) self.assertEquals(1, user.has_role(('Member', 'Authenticated',)))
def test_04_WebPageTranslation(self, quiet=quiet, run=run_all_test): def test_04_WebPageTranslation(self, quiet=quiet, run=run_all_test):
""" """
Simple Case of showing the proper Web Page based on Simple Case of showing the proper Web Page based on
current user selected language in browser. current user selected language in browser.
""" """
if not run: return if not run: return
...@@ -256,7 +251,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -256,7 +251,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
websection = self.setupWebSection() websection = self.setupWebSection()
page_reference = 'default-webpage' page_reference = 'default-webpage'
webpage_list = self.setupWebSitePages(prefix = page_reference) webpage_list = self.setupWebSitePages(prefix = page_reference)
# set default web page for section # set default web page for section
found_by_reference = portal.portal_catalog(name = page_reference, found_by_reference = portal.portal_catalog(name = page_reference,
portal_type = 'Web Page') portal_type = 'Web Page')
...@@ -267,18 +262,18 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -267,18 +262,18 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
# even though we create many pages we should get only one # even though we create many pages we should get only one
# this is the most recent one since all share the same reference # this is the most recent one since all share the same reference
self.assertEquals(1, len(websection.WebSection_getDocumentValueList())) self.assertEquals(1, len(websection.WebSection_getDocumentValueList()))
# use already created few pages in different languages with same reference # use already created few pages in different languages with same reference
# and check that we always get the right one based on selected # and check that we always get the right one based on selected
# by us language # by us language
for language in LANGUAGE_LIST: for language in LANGUAGE_LIST:
# set default language in Localizer only to check that we get # set default language in Localizer only to check that we get
# the corresponding web page for language. # the corresponding web page for language.
# XXX: Extend API so we can select language from REQUEST # 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() default_document = websection.getDefaultDocumentValue()
self.assertEquals(language, default_document.getLanguage()) self.assertEquals(language, default_document.getLanguage())
def test_05_WebPageTextContentSubstitutions(self, quiet=quiet, run=run_all_test): def test_05_WebPageTextContentSubstitutions(self, quiet=quiet, run=run_all_test):
""" """
Simple Case of showing the proper text content with and without a substitution Simple Case of showing the proper text content with and without a substitution
...@@ -294,9 +289,9 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -294,9 +289,9 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
mapping = dict(toto='foo', titi='bar') mapping = dict(toto='foo', titi='bar')
portal = self.getPortal() portal = self.getPortal()
document = portal.web_page_module.newContent(portal_type='Web Page', document = portal.web_page_module.newContent(portal_type='Web Page',
text_content=content) text_content=content)
# No substitution should occur. # No substitution should occur.
self.assertEquals(document.asStrippedHTML(), content) self.assertEquals(document.asStrippedHTML(), content)
...@@ -318,28 +313,28 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -318,28 +313,28 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
Testing the default document for a Web Section. Testing the default document for a Web Section.
If a Web Section has a default document defined and if that default If a Web Section has a default document defined and if that default
document is published, then getDefaultDocumentValue on that document is published, then getDefaultDocumentValue on that
web section should return the latest version in the most web section should return the latest version in the most
appropriate language of that default document. appropriate language of that default document.
Note: due to generic ERP5 Web implementation this test highly depends Note: due to generic ERP5 Web implementation this test highly depends
on WebSection_geDefaulttDocumentValueList on WebSection_geDefaulttDocumentValueList
""" """
if not run: return if not run: return
if not quiet: if not quiet:
message = '\ntest_06_DefaultDocumentForWebSection' message = '\ntest_06_DefaultDocumentForWebSection'
ZopeTestCase._print(message) ZopeTestCase._print(message)
portal = self.getPortal() portal = self.getPortal()
website = self.setupWebSite() website = self.setupWebSite()
websection = self.setupWebSection() websection = self.setupWebSection()
publication_section_category_id_list = ['documentation', 'administration'] publication_section_category_id_list = ['documentation', 'administration']
# create pages belonging to this publication_section 'documentation' # create pages belonging to this publication_section 'documentation'
web_page_en = portal.web_page_module.newContent(portal_type = 'Web Page', web_page_en = portal.web_page_module.newContent(portal_type = 'Web Page',
id='section_home', id='section_home',
language = 'en', language = 'en',
reference='NXD-DDP', reference='NXD-DDP',
publication_section_list=publication_section_category_id_list[:1]) publication_section_list=publication_section_category_id_list[:1])
websection.setAggregateValue(web_page_en) websection.setAggregateValue(web_page_en)
transaction.commit() transaction.commit()
self.tic() self.tic()
...@@ -356,33 +351,33 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -356,33 +351,33 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
base_list = re.findall(Document.base_parser, str(html_page)) base_list = re.findall(Document.base_parser, str(html_page))
base_url = base_list[0] 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, quiet=quiet, run=run_all_test): def test_06b_DefaultDocumentForWebSite(self, quiet=quiet, run=run_all_test):
""" """
Testing the default document for a Web Site. Testing the default document for a Web Site.
If a Web Section has a default document defined and if that default If a Web Section has a default document defined and if that default
document is published, then getDefaultDocumentValue on that document is published, then getDefaultDocumentValue on that
web section should return the latest version in the most web section should return the latest version in the most
appropriate language of that default document. appropriate language of that default document.
Note: due to generic ERP5 Web implementation this test highly depends Note: due to generic ERP5 Web implementation this test highly depends
on WebSection_geDefaulttDocumentValueList on WebSection_geDefaulttDocumentValueList
""" """
if not run: return if not run: return
if not quiet: if not quiet:
message = '\ntest_06b_DefaultDocumentForWebSite' message = '\ntest_06b_DefaultDocumentForWebSite'
ZopeTestCase._print(message) ZopeTestCase._print(message)
portal = self.getPortal() portal = self.getPortal()
website = self.setupWebSite() website = self.setupWebSite()
publication_section_category_id_list = ['documentation', 'administration'] publication_section_category_id_list = ['documentation', 'administration']
# create pages belonging to this publication_section 'documentation' # create pages belonging to this publication_section 'documentation'
web_page_en = portal.web_page_module.newContent(portal_type = 'Web Page', web_page_en = portal.web_page_module.newContent(portal_type = 'Web Page',
id='site_home', id='site_home',
language = 'en', language = 'en',
reference='NXD-DDP-Site', reference='NXD-DDP-Site',
publication_section_list=publication_section_category_id_list[:1]) publication_section_list=publication_section_category_id_list[:1])
website.setAggregateValue(web_page_en) website.setAggregateValue(web_page_en)
transaction.commit() transaction.commit()
self.tic() self.tic()
...@@ -446,7 +441,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -446,7 +441,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
'07', '10', '08', '14' ] '07', '10', '08', '14' ]
sequence_three = ['05', '12', '13', '14', '06', '09', '10', '07', '03', '01', '02', sequence_three = ['05', '12', '13', '14', '06', '09', '10', '07', '03', '01', '02',
'11', '04', '08' , '15'] '11', '04', '08' , '15']
sequence_count = 0 sequence_count = 0
for sequence in [ sequence_one , sequence_two , sequence_three ]: for sequence in [ sequence_one , sequence_two , sequence_three ]:
sequence_count += 1 sequence_count += 1
...@@ -461,17 +456,17 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -461,17 +456,17 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
title=key, title=key,
portal_type = 'Web Page', portal_type = 'Web Page',
publication_section_list=publication_section_category_id_list[:1]) publication_section_list=publication_section_category_id_list[:1])
web_page.edit(**property_dict[key]) web_page.edit(**property_dict[key])
transaction.commit() transaction.commit()
self.tic() self.tic()
web_page_list.append(web_page) web_page_list.append(web_page)
transaction.commit() transaction.commit()
self.tic() self.tic()
# in draft state, no documents should belong to this Web Section # in draft state, no documents should belong to this Web Section
self.assertEqual(0, len(websection.getDocumentValueList())) self.assertEqual(0, len(websection.getDocumentValueList()))
# when published, all web pages should belong to it # when published, all web pages should belong to it
for web_page in web_page_list: for web_page in web_page_list:
web_page.publish() web_page.publish()
...@@ -483,14 +478,14 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -483,14 +478,14 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
# Testing for language parameter # Testing for language parameter
self.assertEqual(4, len(websection.getDocumentValueList())) self.assertEqual(4, len(websection.getDocumentValueList()))
self.assertEqual(['en' , 'en', 'en', 'en'], self.assertEqual(['en' , 'en', 'en', 'en'],
[ w.getLanguage() for w in websection.getDocumentValueList()]) [ w.getLanguage() for w in websection.getDocumentValueList()])
pt_document_value_list = websection.getDocumentValueList(language='pt') pt_document_value_list = websection.getDocumentValueList(language='pt')
self.assertEqual(4, len(pt_document_value_list)) self.assertEqual(4, len(pt_document_value_list))
self.assertEqual(['pt' , 'pt', 'pt', 'pt'], self.assertEqual(['pt' , 'pt', 'pt', 'pt'],
[ w.getObject().getLanguage() for w in pt_document_value_list]) [ w.getObject().getLanguage() for w in pt_document_value_list])
ja_document_value_list = websection.getDocumentValueList(language='ja') ja_document_value_list = websection.getDocumentValueList(language='ja')
self.assertEqual(4, len(ja_document_value_list)) self.assertEqual(4, len(ja_document_value_list))
self.assertEqual(['ja' , 'ja', 'ja', 'ja'], self.assertEqual(['ja' , 'ja', 'ja', 'ja'],
...@@ -508,7 +503,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -508,7 +503,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertEqual(['pt' , 'pt', 'pt', 'pt', 'pt'], self.assertEqual(['pt' , 'pt', 'pt', 'pt', 'pt'],
[ w.getObject().getLanguage() for w in pt_document_value_list]) [ w.getObject().getLanguage() for w in pt_document_value_list])
ja_document_value_list = websection.getDocumentValueList(language='ja', ja_document_value_list = websection.getDocumentValueList(language='ja',
all_versions=1) all_versions=1)
self.assertEqual(5, len(ja_document_value_list)) self.assertEqual(5, len(ja_document_value_list))
self.assertEqual(['ja' , 'ja', 'ja', 'ja', 'ja'], self.assertEqual(['ja' , 'ja', 'ja', 'ja', 'ja'],
...@@ -541,7 +536,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -541,7 +536,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
if w.getLanguage() == 'ja'])) 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']) if w.getLanguage() == 'ja'])
ja_document_value_list = websection.WebSection_getDocumentValueListBase(all_languages=1, ja_document_value_list = websection.WebSection_getDocumentValueListBase(all_languages=1,
language='ja') language='ja')
self.assertEqual(6, len(ja_document_value_list)) self.assertEqual(6, len(ja_document_value_list))
...@@ -556,7 +551,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -556,7 +551,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
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']) if w.getLanguage() == 'en'])
# Tests for all_languages and all_versions # Tests for all_languages and all_versions
en_document_value_list = websection.WebSection_getDocumentValueListBase(all_languages=1, en_document_value_list = websection.WebSection_getDocumentValueListBase(all_languages=1,
all_versions=1) all_versions=1)
...@@ -568,7 +563,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -568,7 +563,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
all_versions=1, all_versions=1,
language='ja') 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]: ja_document_value_list]:
self.assertEqual(15, len(document_value_list)) self.assertEqual(15, len(document_value_list))
...@@ -592,7 +587,6 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -592,7 +587,6 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
[ w.getReference() for w in \ [ w.getReference() for w in \
websection.getDocumentValueList(sort_on=[('reference', 'DESC')])]) websection.getDocumentValueList(sort_on=[('reference', 'DESC')])])
self.assertEqual(['13' , '03', '02', '01'], self.assertEqual(['13' , '03', '02', '01'],
[ w.getTitle() for w in \ [ w.getTitle() for w in \
websection.getDocumentValueList(sort_on=[('reference', 'DESC')])]) websection.getDocumentValueList(sort_on=[('reference', 'DESC')])])
...@@ -601,13 +595,12 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -601,13 +595,12 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
[ w.getReference() for w in \ [ w.getReference() for w in \
websection.WebSection_getDocumentValueListBase(all_languages=1, websection.WebSection_getDocumentValueListBase(all_languages=1,
sort_on=[('reference', 'ASC')])]) sort_on=[('reference', 'ASC')])])
self.assertEqual(['01' , '02', '03', '11' , '12' , '13'], self.assertEqual(['01' , '02', '03', '11' , '12' , '13'],
[ w.getTitle() for w in \ [ w.getTitle() for w in \
websection.WebSection_getDocumentValueListBase(all_languages=1, websection.WebSection_getDocumentValueListBase(all_languages=1,
sort_on=[('title', 'ASC')])]) sort_on=[('title', 'ASC')])])
self.assertEqual(['F' , 'E', 'D', 'C' , 'B' , 'A'], self.assertEqual(['F' , 'E', 'D', 'C' , 'B' , 'A'],
[ w.getReference() for w in \ [ w.getReference() for w in \
websection.WebSection_getDocumentValueListBase(all_languages=1, websection.WebSection_getDocumentValueListBase(all_languages=1,
...@@ -628,7 +621,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -628,7 +621,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
if not run: return if not run: return
if not quiet: if not quiet:
message = '\ntest_08_AcquisitionWrappers' message = '\ntest_08_AcquisitionWrappers'
ZopeTestCase._print(message) ZopeTestCase._print(message)
portal = self.getPortal() portal = self.getPortal()
...@@ -646,7 +639,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -646,7 +639,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
membership_criterion_base_category_list=('publication_section',), membership_criterion_base_category_list=('publication_section',),
membership_criterion_category=('publication_section/my_test_category',), membership_criterion_category=('publication_section/my_test_category',),
) )
# Create at least two documents which belong to the publication section # Create at least two documents which belong to the publication section
# category. # category.
web_page_list = self.setupWebSitePages('test1', web_page_list = self.setupWebSitePages('test1',
...@@ -660,7 +653,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -660,7 +653,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
websection.setAggregateValue(web_page_list[0]) websection.setAggregateValue(web_page_list[0])
transaction.commit() transaction.commit()
self.tic() self.tic()
# Obtain documens in various ways. # Obtain documens in various ways.
default_document = websection.getDefaultDocumentValue() default_document = websection.getDefaultDocumentValue()
self.assertNotEquals(default_document, None) self.assertNotEquals(default_document, None)
...@@ -686,7 +679,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -686,7 +679,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
if not run: return if not run: return
if not quiet: if not quiet:
message = '\ntest_09_WebSiteSkinSelection' message = '\ntest_09_WebSiteSkinSelection'
ZopeTestCase._print(message) ZopeTestCase._print(message)
portal = self.getPortal() portal = self.getPortal()
ps = portal.portal_skins ps = portal.portal_skins
...@@ -706,7 +699,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -706,7 +699,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
if ps.getSkinPath('Test ERP5 Web') is not None: if ps.getSkinPath('Test ERP5 Web') is not None:
ps.manage_skinLayers(del_skin=1, chosen=('Test ERP5 Web',)) ps.manage_skinLayers(del_skin=1, chosen=('Test ERP5 Web',))
path = ps.getSkinPath(ps.getDefaultSkin()) path = ps.getSkinPath(ps.getDefaultSkin())
self.assertNotEquals(path, None) self.assertNotEquals(path, None)
ps.manage_skinLayers(add_skin=1, skinname='Test ERP5 Web', ps.manage_skinLayers(add_skin=1, skinname='Test ERP5 Web',
...@@ -744,7 +737,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -744,7 +737,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
if not quiet: if not quiet:
message = '\ntest_10_getDocumentValueList' message = '\ntest_10_getDocumentValueList'
ZopeTestCase._print(message) ZopeTestCase._print(message)
self.setupWebSite() self.setupWebSite()
website = self.web_site_module[self.website_id] website = self.web_site_module[self.website_id]
website.getDocumentValueList( website.getDocumentValueList(
...@@ -795,7 +788,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -795,7 +788,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
web_section.setVisible(1) web_section.setVisible(1)
sub_web_section.setVisible(0) sub_web_section.setVisible(0)
_commit() _commit()
self.assertSameSet([web_section], self.assertSameSet([web_section],
web_site.getWebSectionValueList(web_page)) web_site.getWebSectionValueList(web_page))
# Set both web section visible # Set both web section visible
...@@ -803,7 +796,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -803,7 +796,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
web_section.setVisible(1) web_section.setVisible(1)
sub_web_section.setVisible(1) sub_web_section.setVisible(1)
_commit() _commit()
self.assertSameSet([sub_web_section], self.assertSameSet([sub_web_section],
web_site.getWebSectionValueList(web_page)) web_site.getWebSectionValueList(web_page))
# Set leaf web section visible, which should be returned even if parent is # Set leaf web section visible, which should be returned even if parent is
...@@ -811,7 +804,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -811,7 +804,7 @@ class TestERP5Web(ERP5TypeTestCase, ZopeTestCase.Functional):
web_section.setVisible(0) web_section.setVisible(0)
sub_web_section.setVisible(1) sub_web_section.setVisible(1)
_commit() _commit()
self.assertSameSet([sub_web_section], self.assertSameSet([sub_web_section],
web_site.getWebSectionValueList(web_page)) web_site.getWebSectionValueList(web_page))
def test_12_getWebSiteValue(self, quiet=quiet, run=run_all_test): def test_12_getWebSiteValue(self, quiet=quiet, run=run_all_test):
...@@ -936,7 +929,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -936,7 +929,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
def beforeTearDown(self): def beforeTearDown(self):
self.clearModule(self.portal.web_site_module) self.clearModule(self.portal.web_site_module)
self.clearModule(self.portal.web_page_module) self.clearModule(self.portal.web_page_module)
def test_01_AccessWebPageByReference(self, quiet=quiet, run=run_all_test): def test_01_AccessWebPageByReference(self, quiet=quiet, run=run_all_test):
if not run: return if not run: return
if not quiet: if not quiet:
...@@ -1000,7 +993,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1000,7 +993,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
target = self.portal.restrictedTraverse('web_site_module/site/section/my-first-web-page') target = self.portal.restrictedTraverse('web_site_module/site/section/my-first-web-page')
self.assertEqual('こんにちは、世界!', target.getTextContent()) self.assertEqual('こんにちは、世界!', target.getTextContent())
def test_02_LocalRolesFromRoleDefinition(self, quiet=quiet, run=run_all_test): def test_02_LocalRolesFromRoleDefinition(self, quiet=quiet, run=run_all_test):
""" Test setting local roles on Web Site/ Web Sectio using ERP5 Role Definition objects . """ """ Test setting local roles on Web Site/ Web Sectio using ERP5 Role Definition objects . """
if not run: return if not run: return
...@@ -1012,34 +1005,33 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1012,34 +1005,33 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
site = portal.web_site_module.newContent(portal_type='Web Site', site = portal.web_site_module.newContent(portal_type='Web Site',
id='site') id='site')
section = site.newContent(portal_type='Web Section', id='section') section = site.newContent(portal_type='Web Section', id='section')
person = portal.person_module.newContent(portal_type = 'Person', person = portal.person_module.newContent(portal_type = 'Person',
reference = person_reference) reference = person_reference)
# add Role Definition for site and section # add Role Definition for site and section
site_role_definition = site.newContent(portal_type = 'Role Definition', site_role_definition = site.newContent(portal_type = 'Role Definition',
role_name = 'Assignee', role_name = 'Assignee',
agent = person.getRelativeUrl()) agent = person.getRelativeUrl())
section_role_definition = section.newContent(portal_type = 'Role Definition', section_role_definition = section.newContent(portal_type = 'Role Definition',
role_name = 'Associate', role_name = 'Associate',
agent = person.getRelativeUrl()) agent = person.getRelativeUrl())
transaction.commit() transaction.commit()
self.tic() self.tic()
# check if Role Definition have create local roles # check if Role Definition have create local roles
self.assertSameSet(('Assignee',), self.assertSameSet(('Assignee',),
site.get_local_roles_for_userid(person_reference)) site.get_local_roles_for_userid(person_reference))
self.assertSameSet(('Associate',), self.assertSameSet(('Associate',),
section.get_local_roles_for_userid(person_reference)) section.get_local_roles_for_userid(person_reference))
# delete Role Definition and check again (local roles must be gone too) # delete Role Definition and check again (local roles must be gone too)
site.manage_delObjects(site_role_definition.getId()) site.manage_delObjects(site_role_definition.getId())
section.manage_delObjects(section_role_definition.getId()) section.manage_delObjects(section_role_definition.getId())
transaction.commit() transaction.commit()
self.tic() self.tic()
self.assertSameSet((), self.assertSameSet((),
site.get_local_roles_for_userid(person_reference)) site.get_local_roles_for_userid(person_reference))
self.assertSameSet((), self.assertSameSet((),
section.get_local_roles_for_userid(person_reference)) section.get_local_roles_for_userid(person_reference))
def test_03_WebSection_getDocumentValueListSecurity(self, quiet=quiet, run=run_all_test): def test_03_WebSection_getDocumentValueListSecurity(self, quiet=quiet, run=run_all_test):
""" Test WebSection_getDocumentValueList behaviour and security""" """ Test WebSection_getDocumentValueList behaviour and security"""
if not run: return if not run: return
...@@ -1051,14 +1043,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1051,14 +1043,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
site = web_site_module.newContent(portal_type='Web Site', site = web_site_module.newContent(portal_type='Web Site',
id='site') id='site')
section = site.newContent(portal_type='Web Section', section = site.newContent(portal_type='Web Section',
id='section') id='section')
transaction.commit() transaction.commit()
self.tic() self.tic()
section.setCriterionProperty('portal_type') section.setCriterionProperty('portal_type')
section.setCriterion('portal_type', max='', section.setCriterion('portal_type', max='',
identity=['Web Page'], min='') identity=['Web Page'], min='')
transaction.commit() transaction.commit()
...@@ -1093,14 +1085,12 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1093,14 +1085,12 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
text_format='text/plain', text_format='text/plain',
text_content='Hello, World!') text_content='Hello, World!')
transaction.commit() transaction.commit()
self.changeUser('erp5user') self.changeUser('erp5user')
self.tic() self.tic()
self.portal.Localizer.changeLanguage('en') self.portal.Localizer.changeLanguage('en')
self.assertEquals(0, len(section.WebSection_getDocumentValueList())) self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
self.changeUser('erp5user') self.changeUser('erp5user')
page_en_0.publish() page_en_0.publish()
...@@ -1119,7 +1109,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1119,7 +1109,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self.logout() self.logout()
self.portal.Localizer.changeLanguage('en') self.portal.Localizer.changeLanguage('en')
self.assertEquals(1, len(section.WebSection_getDocumentValueList())) self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_en_0.getUid(), self.assertEquals(page_en_0.getUid(),
section.WebSection_getDocumentValueList()[0].getUid()) section.WebSection_getDocumentValueList()[0].getUid())
self.portal.Localizer.changeLanguage('jp') self.portal.Localizer.changeLanguage('jp')
self.assertEquals(0, len(section.WebSection_getDocumentValueList())) self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
...@@ -1132,7 +1122,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1132,7 +1122,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self.portal.Localizer.changeLanguage('en') self.portal.Localizer.changeLanguage('en')
self.assertEquals(1, len(section.WebSection_getDocumentValueList())) self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_en_1.getUid(), self.assertEquals(page_en_1.getUid(),
section.WebSection_getDocumentValueList()[0].getUid()) section.WebSection_getDocumentValueList()[0].getUid())
self.portal.Localizer.changeLanguage('jp') self.portal.Localizer.changeLanguage('jp')
self.assertEquals(0, len(section.WebSection_getDocumentValueList())) self.assertEquals(0, len(section.WebSection_getDocumentValueList()))
...@@ -1141,7 +1131,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1141,7 +1131,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self.logout() self.logout()
self.portal.Localizer.changeLanguage('en') self.portal.Localizer.changeLanguage('en')
self.assertEquals(1, len(section.WebSection_getDocumentValueList())) self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_en_1.getUid(), self.assertEquals(page_en_1.getUid(),
section.WebSection_getDocumentValueList()[0].getUid()) section.WebSection_getDocumentValueList()[0].getUid())
# Trird Object # Trird Object
...@@ -1179,10 +1169,9 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1179,10 +1169,9 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self.assertEquals(2, len(section.WebSection_getDocumentValueList())) self.assertEquals(2, len(section.WebSection_getDocumentValueList()))
self.portal.Localizer.changeLanguage('jp') self.portal.Localizer.changeLanguage('jp')
self.assertEquals(1, len(section.WebSection_getDocumentValueList())) self.assertEquals(1, len(section.WebSection_getDocumentValueList()))
self.assertEquals(page_jp_0.getUid(), self.assertEquals(page_jp_0.getUid(),
section.WebSection_getDocumentValueList()[0].getUid()) section.WebSection_getDocumentValueList()[0].getUid())
def test_04_ExpireUserAction(self, quiet=quiet, run=run_all_test): def test_04_ExpireUserAction(self, quiet=quiet, run=run_all_test):
""" Test the expire user action""" """ Test the expire user action"""
if not run: return if not run: return
...@@ -1210,7 +1199,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1210,7 +1199,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
section_5.expire() section_5.expire()
except Unauthorized: except Unauthorized:
self.fail("Admin should be able to expire a Web Section.") self.fail("Admin should be able to expire a Web Section.")
# test if a user (ASSIGNOR) can expire them # test if a user (ASSIGNOR) can expire them
self.changeUser('webmaster') self.changeUser('webmaster')
try: try:
...@@ -1218,14 +1207,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1218,14 +1207,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
section_6.expire() section_6.expire()
except Unauthorized: except Unauthorized:
self.fail("An user should be able to expire a Web Section.") self.fail("An user should be able to expire a Web Section.")
def test_05_createWebSite(self, quiet=quiet, run=run_all_test): def test_05_createWebSite(self, quiet=quiet, run=run_all_test):
""" Test to create or clone web sites with many users """ """ Test to create or clone web sites with many users """
if not run: return if not run: return
if not quiet: if not quiet:
message = '\ntest_05_createWebSite' message = '\ntest_05_createWebSite'
ZopeTestCase._print(message) ZopeTestCase._print(message)
self.changeUser('admin') self.changeUser('admin')
web_site_module = self.portal.web_site_module web_site_module = self.portal.web_site_module
...@@ -1236,7 +1225,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1236,7 +1225,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self.fail("Admin should be able to create a Web Site.") self.fail("Admin should be able to create a Web Site.")
# test as a web user (assignor) # test as a web user (assignor)
self.changeUser('webmaster') self.changeUser('webmaster')
try: try:
site_2 = web_site_module.newContent(portal_type='Web Site', id='site_2') site_2 = web_site_module.newContent(portal_type='Web Site', id='site_2')
except Unauthorized: except Unauthorized:
...@@ -1253,7 +1242,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1253,7 +1242,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
if not quiet: if not quiet:
message = '\ntest_06_createWebSection' message = '\ntest_06_createWebSection'
ZopeTestCase._print(message) ZopeTestCase._print(message)
self.changeUser('admin') self.changeUser('admin')
web_site_module = self.portal.web_site_module web_site_module = self.portal.web_site_module
site = web_site_module.newContent(portal_type='Web Site', id='site') site = web_site_module.newContent(portal_type='Web Site', id='site')
...@@ -1280,14 +1269,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1280,14 +1269,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
section_3_clone = section_2[section_2.manage_pasteObjects( section_3_clone = section_2[section_2.manage_pasteObjects(
section_3_copy)[0]['new_id']] section_3_copy)[0]['new_id']]
self.assertEquals(section_3_clone.getPortalType(), 'Web Section') self.assertEquals(section_3_clone.getPortalType(), 'Web Section')
def test_07_createCategory(self, quiet=quiet, run=run_all_test): def test_07_createCategory(self, quiet=quiet, run=run_all_test):
""" Test to create or clone categories with many users """ """ Test to create or clone categories with many users """
if not run: return if not run: return
if not quiet: if not quiet:
message = '\ntest_07_createCategory' message = '\ntest_07_createCategory'
ZopeTestCase._print(message) ZopeTestCase._print(message)
self.changeUser('admin') self.changeUser('admin')
portal_categories = self.portal.portal_categories portal_categories = self.portal.portal_categories
publication_section = portal_categories.publication_section publication_section = portal_categories.publication_section
...@@ -1312,7 +1301,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1312,7 +1301,7 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
self.assertEquals(category_2_clone.getPortalType(), 'Category') self.assertEquals(category_2_clone.getPortalType(), 'Category')
# test as a web user (assignor) # test as a web user (assignor)
self.changeUser('webmaster') self.changeUser('webmaster')
try: try:
base_category_2 = portal_categories.newContent(portal_type='Base Category', id='base_category_2') base_category_2 = portal_categories.newContent(portal_type='Base Category', id='base_category_2')
self.fail("A webmaster should not be able to create a Base Category.") self.fail("A webmaster should not be able to create a Base Category.")
...@@ -1339,15 +1328,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1339,15 +1328,14 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
category_4_clone = category_3[category_3.manage_pasteObjects( category_4_clone = category_3[category_3.manage_pasteObjects(
category_4_copy)[0]['new_id']] category_4_copy)[0]['new_id']]
self.assertEquals(category_4_clone.getPortalType(), 'Category') self.assertEquals(category_4_clone.getPortalType(), 'Category')
def test_08_createAndrenameCategory(self, quiet=quiet, run=run_all_test): def test_08_createAndrenameCategory(self, quiet=quiet, run=run_all_test):
""" Test to create or rename categories with many users """ """ Test to create or rename categories with many users """
if not run: return if not run: return
if not quiet: if not quiet:
message = '\ntest_08_createAndrenameCategory' message = '\ntest_08_createAndrenameCategory'
ZopeTestCase._print(message) ZopeTestCase._print(message)
self.changeUser('admin') self.changeUser('admin')
portal_categories = self.portal.portal_categories portal_categories = self.portal.portal_categories
publication_section = portal_categories.publication_section publication_section = portal_categories.publication_section
...@@ -1360,18 +1348,18 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1360,18 +1348,18 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
try: try:
new_category_1 = publication_section.newContent(portal_type='Category', id='new_category_1') new_category_1 = publication_section.newContent(portal_type='Category', id='new_category_1')
new_category_2 = new_category_1.newContent(portal_type='Category', new_category_2 = new_category_1.newContent(portal_type='Category',
id='new_category_2') id='new_category_2')
except Unauthorized: except Unauthorized:
self.fail("Admin should be able to create a Category.") self.fail("Admin should be able to create a Category.")
transaction.commit() transaction.commit()
self.tic() self.tic()
try: try:
new_cat_1_renamed = new_category_1.edit(id='new_cat_1_renamed') new_cat_1_renamed = new_category_1.edit(id='new_cat_1_renamed')
new_cat_2_renamed = new_category_2.edit(id='new_cat_2_renamed') new_cat_2_renamed = new_category_2.edit(id='new_cat_2_renamed')
except Unauthorized: except Unauthorized:
self.fail("Admin should be able to rename a Category.") self.fail("Admin should be able to rename a Category.")
# test as a web user (assignor) # test as a web user (assignor)
self.changeUser('webmaster') self.changeUser('webmaster')
try: try:
base_category_2 = portal_categories.newContent(portal_type='Base Category', id='base_category_2') base_category_2 = portal_categories.newContent(portal_type='Base Category', id='base_category_2')
self.fail("A webmaster should not be able to create a Base Category.") self.fail("A webmaster should not be able to create a Base Category.")
...@@ -1381,17 +1369,17 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase): ...@@ -1381,17 +1369,17 @@ class TestERP5WebWithSimpleSecurity(ERP5TypeTestCase):
new_category_3 = publication_section.newContent( 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', new_category_4 = new_category_3.newContent(portal_type='Category',
id='new_category_4') id='new_category_4')
except Unauthorized: except Unauthorized:
self.fail("A webmaster should be able to create a Category.") self.fail("A webmaster should be able to create a Category.")
transaction.commit() transaction.commit()
self.tic() self.tic()
try: try:
new_cat_3_renamed = new_category_3.edit(id='new_cat_3_renamed') new_cat_3_renamed = new_category_3.edit(id='new_cat_3_renamed')
new_cat_4_renamed = new_category_4.edit(id='new_cat_4_renamed') new_cat_4_renamed = new_category_4.edit(id='new_cat_4_renamed')
except Unauthorized: except Unauthorized:
self.fail("A webmaster should be able to rename a Category.") self.fail("A webmaster should be able to rename a Category.")
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Web)) suite.addTest(unittest.makeSuite(TestERP5Web))
......
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