Commit abd6428e authored by Ivan Tyagov's avatar Ivan Tyagov

Test redirect to Person object & Preferences for logged in user.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44623 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8c207bee
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
import re import re
import unittest import unittest
import transaction import transaction
from AccessControl import Unauthorized from AccessControl import Unauthorized
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -108,8 +107,7 @@ class TestERP5Web(ERP5TypeTestCase): ...@@ -108,8 +107,7 @@ class TestERP5Web(ERP5TypeTestCase):
id = self.website_id, id = self.website_id,
**kw) **kw)
website.publish() website.publish()
transaction.commit() self.stepTic()
self.tic()
return website return website
def setupWebSection(self, **kw): def setupWebSection(self, **kw):
...@@ -129,8 +127,7 @@ class TestERP5Web(ERP5TypeTestCase): ...@@ -129,8 +127,7 @@ class TestERP5Web(ERP5TypeTestCase):
max='', max='',
min='') min='')
transaction.commit() self.stepTic()
self.tic()
return websection return websection
def setupWebSitePages(self, prefix, suffix=None, version='0.1', def setupWebSitePages(self, prefix, suffix=None, version='0.1',
...@@ -156,8 +153,7 @@ class TestERP5Web(ERP5TypeTestCase): ...@@ -156,8 +153,7 @@ class TestERP5Web(ERP5TypeTestCase):
language=language, language=language,
**kw) **kw)
webpage.publish() webpage.publish()
transaction.commit() self.stepTic()
self.tic()
self.assertEquals(language, webpage.getLanguage()) self.assertEquals(language, webpage.getLanguage())
self.assertEquals(reference, webpage.getReference()) self.assertEquals(reference, webpage.getReference())
self.assertEquals(version, webpage.getVersion()) self.assertEquals(version, webpage.getVersion())
...@@ -201,12 +197,10 @@ class TestERP5Web(ERP5TypeTestCase): ...@@ -201,12 +197,10 @@ class TestERP5Web(ERP5TypeTestCase):
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 = self.web_page_module.newContent(portal_type='Web Page')
page.edit(text_content='<p>Hé Hé Hé!</p>') page.edit(text_content='<p>Hé Hé Hé!</p>')
transaction.commit() self.stepTic()
self.tic()
self.assertEquals('Hé Hé Hé!', page.asText().strip()) self.assertEquals('Hé Hé Hé!', page.asText().strip())
page.edit(text_content='<p>Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé!</p>') page.edit(text_content='<p>Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé!</p>')
transaction.commit() self.stepTic()
self.tic()
self.assertEquals("""Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé self.assertEquals("""Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé Hé
Hé Hé Hé!""", page.asText().strip()) Hé Hé Hé!""", page.asText().strip())
...@@ -228,8 +222,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -228,8 +222,7 @@ Hé Hé Hé!""", page.asText().strip())
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() self.stepTic()
self.tic()
# find person object by reference # find person object by reference
person = website.ERP5Site_getAuthenticatedMemberPersonValue(kw['reference']) person = website.ERP5Site_getAuthenticatedMemberPersonValue(kw['reference'])
...@@ -244,6 +237,21 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -244,6 +237,21 @@ Hé Hé Hé!""", page.asText().strip())
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',)))
self.login(kw['reference'])
self.assertEquals(kw['reference'], str(self.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']))
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']))
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',
'owner': kw['reference']})[0][0])
def test_04_WebPageTranslation(self): def test_04_WebPageTranslation(self):
""" """
...@@ -337,13 +345,11 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -337,13 +345,11 @@ Hé Hé Hé!""", page.asText().strip())
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() self.stepTic()
self.tic()
self.assertEqual(None, websection.getDefaultDocumentValue()) self.assertEqual(None, websection.getDefaultDocumentValue())
# publish it # publish it
web_page_en.publish() web_page_en.publish()
transaction.commit() self.stepTic()
self.tic()
self.assertEqual(web_page_en, websection.getDefaultDocumentValue()) self.assertEqual(web_page_en, websection.getDefaultDocumentValue())
# and make sure that the base meta tag which is generated # and make sure that the base meta tag which is generated
# uses the web section rather than the portal # uses the web section rather than the portal
...@@ -376,13 +382,11 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -376,13 +382,11 @@ Hé Hé Hé!""", page.asText().strip())
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() self.stepTic()
self.tic()
self.assertEqual(None, website.getDefaultDocumentValue()) self.assertEqual(None, website.getDefaultDocumentValue())
# publish it # publish it
web_page_en.publish() web_page_en.publish()
transaction.commit() self.stepTic()
self.tic()
self.assertEqual(web_page_en, website.getDefaultDocumentValue()) self.assertEqual(web_page_en, website.getDefaultDocumentValue())
# and make sure that the base meta tag which is generated # and make sure that the base meta tag which is generated
# uses the web site rather than the portal # uses the web site rather than the portal
...@@ -450,20 +454,17 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -450,20 +454,17 @@ Hé Hé Hé!""", page.asText().strip())
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() self.stepTic()
self.tic()
web_page_list.append(web_page) web_page_list.append(web_page)
transaction.commit() self.stepTic()
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()
transaction.commit() self.stepTic()
self.tic()
# Test for limit parameter # Test for limit parameter
self.assertEqual(2, len(websection.getDocumentValueList(limit=2))) self.assertEqual(2, len(websection.getDocumentValueList(limit=2)))
...@@ -625,8 +626,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -625,8 +626,7 @@ Hé Hé Hé!""", page.asText().strip())
publication_section.newContent(portal_type='Category', publication_section.newContent(portal_type='Category',
id='my_test_category', id='my_test_category',
title='Test') title='Test')
transaction.commit() self.stepTic()
self.tic()
website = self.setupWebSite() website = self.setupWebSite()
websection = self.setupWebSection( websection = self.setupWebSection(
...@@ -645,8 +645,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -645,8 +645,7 @@ Hé Hé Hé!""", page.asText().strip())
# We need a default document. # We need a default document.
websection.setAggregateValue(web_page_list[0]) websection.setAggregateValue(web_page_list[0])
transaction.commit() self.stepTic()
self.tic()
# Obtain documens in various ways. # Obtain documens in various ways.
default_document = websection.getDefaultDocumentValue() default_document = websection.getDefaultDocumentValue()
...@@ -676,8 +675,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -676,8 +675,7 @@ Hé Hé Hé!""", page.asText().strip())
# First, make sure that we use the default skin selection. # First, make sure that we use the default skin selection.
portal.changeSkin(ps.getDefaultSkin()) portal.changeSkin(ps.getDefaultSkin())
transaction.commit() self.stepTic()
self.tic()
# Make some skin stuff. # Make some skin stuff.
if ps._getOb('test_erp5_web', None) is not None: if ps._getOb('test_erp5_web', None) is not None:
...@@ -702,8 +700,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -702,8 +700,7 @@ Hé Hé Hé!""", page.asText().strip())
'WebSite_test_13_WebSiteSkinSelection', 'WebSite_test_13_WebSiteSkinSelection',
'', 'return "bar"') '', 'return "bar"')
transaction.commit() self.stepTic()
self.tic()
path = website.absolute_url_path() + '/WebSite_test_13_WebSiteSkinSelection' path = website.absolute_url_path() + '/WebSite_test_13_WebSiteSkinSelection'
request = portal.REQUEST request = portal.REQUEST
...@@ -714,8 +711,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -714,8 +711,7 @@ Hé Hé Hé!""", page.asText().strip())
# With the test skin. # With the test skin.
website.setSkinSelectionName('Test ERP5 Web') website.setSkinSelectionName('Test ERP5 Web')
transaction.commit() self.stepTic()
self.tic()
request['PARENTS'] = [self.app] request['PARENTS'] = [self.app]
self.assertEquals(request.traverse(path)(), 'bar') self.assertEquals(request.traverse(path)(), 'bar')
...@@ -750,8 +746,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -750,8 +746,7 @@ Hé Hé Hé!""", page.asText().strip())
# Commit transaction # Commit transaction
def _commit(): def _commit():
portal.portal_caches.clearAllCache() portal.portal_caches.clearAllCache()
transaction.commit() self.stepTic()
self.tic()
# By default, as now Web Section is visible, nothing should be returned # By default, as now Web Section is visible, nothing should be returned
_commit() _commit()
...@@ -813,8 +808,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -813,8 +808,7 @@ Hé Hé Hé!""", page.asText().strip())
reference='foo', reference='foo',
text_content='<b>OK</b>') text_content='<b>OK</b>')
page.publish() page.publish()
transaction.commit() self.stepTic()
self.tic()
webpage = self.portal.restrictedTraverse( webpage = self.portal.restrictedTraverse(
'web_site_module/%s/%s' % (website_id, page_ref)) 'web_site_module/%s/%s' % (website_id, page_ref))
...@@ -882,8 +876,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -882,8 +876,7 @@ Hé Hé Hé!""", page.asText().strip())
reference='NXD-Document.Cache', reference='NXD-Document.Cache',
text_content=content) text_content=content)
document.publish() document.publish()
transaction.commit() self.stepTic()
self.tic()
self.assertEquals(document.asText().strip(), 'initial text') self.assertEquals(document.asText().strip(), 'initial text')
# First make sure conversion already exists on the web site # First make sure conversion already exists on the web site
...@@ -905,8 +898,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -905,8 +898,7 @@ Hé Hé Hé!""", page.asText().strip())
# modified the web_page content # modified the web_page content
document.edit(text_content=new_content) document.edit(text_content=new_content)
self.assertEquals(document.asText().strip(), 'modified text') self.assertEquals(document.asText().strip(), 'modified text')
transaction.commit() self.stepTic()
self.tic()
# check the cache doesn't send again the old content # check the cache doesn't send again the old content
# Through the web_site. # Through the web_site.
...@@ -945,8 +937,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -945,8 +937,7 @@ Hé Hé Hé!""", page.asText().strip())
reference='NXD-Document.Cache', reference='NXD-Document.Cache',
text_content=content) text_content=content)
document.publish() document.publish()
transaction.commit() self.stepTic()
self.tic()
self.assertEquals(document.asText().strip(), 'initial text') self.assertEquals(document.asText().strip(), 'initial text')
# Make sure document cache keeps converted content even if ID changes # Make sure document cache keeps converted content even if ID changes
...@@ -978,8 +969,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -978,8 +969,7 @@ Hé Hé Hé!""", page.asText().strip())
reference='NXD-Document.Cache', reference='NXD-Document.Cache',
text_content=content) text_content=content)
document.publish() document.publish()
transaction.commit() self.stepTic()
self.tic()
self.assertEquals(document.asText().strip(), 'initial text') self.assertEquals(document.asText().strip(), 'initial text')
# Through the web_site. # Through the web_site.
...@@ -1000,8 +990,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1000,8 +990,7 @@ Hé Hé Hé!""", page.asText().strip())
self.assertFalse(document.hasConversion(format='txt')) self.assertFalse(document.hasConversion(format='txt'))
# Make sure cache is regenerated # Make sure cache is regenerated
self.assertEquals(web_document.asText().strip(), 'modified text') self.assertEquals(web_document.asText().strip(), 'modified text')
transaction.commit() self.stepTic()
self.tic()
# First make sure conversion already exists (since it should # First make sure conversion already exists (since it should
# have been generated previously) # have been generated previously)
...@@ -1049,8 +1038,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1049,8 +1038,7 @@ Hé Hé Hé!""", page.asText().strip())
self.createUserAssignement(user, {}) self.createUserAssignement(user, {})
user = self.createUser('webeditor') user = self.createUser('webeditor')
self.createUserAssignement(user, {}) self.createUserAssignement(user, {})
transaction.commit() self.stepTic()
self.tic()
preference_tool = self.getPreferenceTool() preference_tool = self.getPreferenceTool()
isTransitionPossible = self.portal.portal_workflow.isTransitionPossible isTransitionPossible = self.portal.portal_workflow.isTransitionPossible
...@@ -1082,8 +1070,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1082,8 +1070,7 @@ Hé Hé Hé!""", page.asText().strip())
webeditor_preference.setPreferredHtmlStyleDevelopperMode(False) webeditor_preference.setPreferredHtmlStyleDevelopperMode(False)
webeditor_preference.setPreferredHtmlStyleTranslatorMode(True) webeditor_preference.setPreferredHtmlStyleTranslatorMode(True)
self.login() self.login()
transaction.commit() self.stepTic()
self.tic()
web_site = self.setupWebSite() web_site = self.setupWebSite()
websection = self.setupWebSection() websection = self.setupWebSection()
...@@ -1123,8 +1110,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1123,8 +1110,7 @@ Hé Hé Hé!""", page.asText().strip())
reference='NXD-Document.Cache', reference='NXD-Document.Cache',
text_content=content) text_content=content)
document.publish() document.publish()
transaction.commit() self.stepTic()
self.tic()
path = website.absolute_url_path() + '/NXD-Document.Cache' path = website.absolute_url_path() + '/NXD-Document.Cache'
# test Different Policy installed by erp5_web # test Different Policy installed by erp5_web
# unauthenticated web pages # unauthenticated web pages
...@@ -1190,9 +1176,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1190,9 +1176,7 @@ Hé Hé Hé!""", page.asText().strip())
websection = self.setupWebSection() websection = self.setupWebSection()
self.assertEquals(websection.getId(), websection.getTitle()) self.assertEquals(websection.getId(), websection.getTitle())
transaction.commit() self.stepTic()
self.tic()
response = self.publish('/%s/%s/%s/%s/Base_editAndEditAsWeb' % \ response = self.publish('/%s/%s/%s/%s/Base_editAndEditAsWeb' % \
(self.portal.getId(), website.getRelativeUrl(), (self.portal.getId(), website.getRelativeUrl(),
language, websection.getId()), language, websection.getId()),
...@@ -1212,8 +1196,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1212,8 +1196,7 @@ Hé Hé Hé!""", page.asText().strip())
new_location = response.getHeader('Location') new_location = response.getHeader('Location')
new_location = new_location.split('/', 3)[-1] new_location = new_location.split('/', 3)[-1]
transaction.commit() self.stepTic()
self.tic()
response = self.publish(new_location, basic='ERP5TypeTestCase:',) response = self.publish(new_location, basic='ERP5TypeTestCase:',)
self.assertEquals(HTTP_OK, response.getStatus()) self.assertEquals(HTTP_OK, response.getStatus())
...@@ -1221,8 +1204,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1221,8 +1204,7 @@ Hé Hé Hé!""", page.asText().strip())
response.getHeader('content-type')) response.getHeader('content-type'))
self.assertTrue("Data updated." in response.getBody()) self.assertTrue("Data updated." in response.getBody())
transaction.commit() self.stepTic()
self.tic()
self.assertEquals('%s_edited' % websection.getId(), websection.getTitle()) self.assertEquals('%s_edited' % websection.getId(), websection.getTitle())
self.assertEquals(1, len(self.portal.portal_catalog( self.assertEquals(1, len(self.portal.portal_catalog(
...@@ -1252,8 +1234,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1252,8 +1234,7 @@ Hé Hé Hé!""", page.asText().strip())
self.assertEquals(website.getId(), website.getTitle()) self.assertEquals(website.getId(), website.getTitle())
transaction.commit() self.stepTic()
self.tic()
response = self.publish('/%s/%s/%s/Base_editAndEditAsWeb' % \ response = self.publish('/%s/%s/%s/Base_editAndEditAsWeb' % \
(self.portal.getId(), website.getRelativeUrl(), (self.portal.getId(), website.getRelativeUrl(),
...@@ -1274,8 +1255,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1274,8 +1255,7 @@ Hé Hé Hé!""", page.asText().strip())
new_location = response.getHeader('Location') new_location = response.getHeader('Location')
new_location = new_location.split('/', 3)[-1] new_location = new_location.split('/', 3)[-1]
transaction.commit() self.stepTic()
self.tic()
response = self.publish(new_location, basic='ERP5TypeTestCase:',) response = self.publish(new_location, basic='ERP5TypeTestCase:',)
self.assertEquals(HTTP_OK, response.getStatus()) self.assertEquals(HTTP_OK, response.getStatus())
...@@ -1283,8 +1263,7 @@ Hé Hé Hé!""", page.asText().strip()) ...@@ -1283,8 +1263,7 @@ Hé Hé Hé!""", page.asText().strip())
response.getHeader('content-type')) response.getHeader('content-type'))
self.assertTrue("Data updated." in response.getBody()) self.assertTrue("Data updated." in response.getBody())
transaction.commit() self.stepTic()
self.tic()
self.assertEquals('%s_edited' % website.getId(), website.getTitle()) self.assertEquals('%s_edited' % website.getId(), website.getTitle())
self.assertEquals(1, len(self.portal.portal_catalog( self.assertEquals(1, len(self.portal.portal_catalog(
......
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