From c36b33f6e1a218d0361369db792250df6622010c Mon Sep 17 00:00:00 2001
From: Nicolas Delaby <nicolas@nexedi.com>
Date: Wed, 5 May 2010 16:03:05 +0000
Subject: [PATCH] Do not use request.traverse method because it logout the
 user. Use PortalTestCase.publish method instead.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@35015 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/tests/testERP5Web.py | 33 ++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/product/ERP5/tests/testERP5Web.py b/product/ERP5/tests/testERP5Web.py
index e8715837fa..f3ad392715 100644
--- a/product/ERP5/tests/testERP5Web.py
+++ b/product/ERP5/tests/testERP5Web.py
@@ -957,13 +957,15 @@ H茅 H茅 H茅!""", page.asText().strip())
 
     # Through the web_site.
     path = website.absolute_url_path() + '/NXD-Document.Cache'
-    self.assertNotEquals(request.traverse(path)(REQUEST=request.REQUEST,
-      RESPONSE=request.RESPONSE).find(content), -1)
+    response = self.publish(path, '%s:%s' % (self.manager_username,
+                                                        self.manager_password))
+    self.assertNotEquals(response.getBody().find(content), -1)
 
     # Through a web_section.
     path = web_section.absolute_url_path() + '/NXD-Document.Cache'
-    self.assertNotEquals(request.traverse(path)(REQUEST=request.REQUEST,
-      RESPONSE=request.RESPONSE).find(content), -1)
+    response = self.publish(path, '%s:%s' % (self.manager_username,
+                                                        self.manager_password))
+    self.assertNotEquals(response.getBody().find(content), -1)
 
     # modified the web_page content
     document.edit(text_content=new_content)
@@ -1045,7 +1047,7 @@ H茅 H茅 H茅!""", page.asText().strip())
     web_section = website.newContent(portal_type=web_section_portal_type)
 
     content = '<p>initial text</p>'
-    new_content = '<p>modified text<p>'
+    new_content = '<p>modified text</p>'
     document = portal.web_page_module.newContent(portal_type='Web Page',
             id='document_cache',
             reference='NXD-Document.Cache',
@@ -1057,13 +1059,14 @@ H茅 H茅 H茅!""", page.asText().strip())
 
     # Through the web_site.
     path = website.absolute_url_path() + '/NXD-Document.Cache'
-    self.assertNotEquals(request.traverse(path)(REQUEST=request.REQUEST,
-      RESPONSE=request.RESPONSE).find(content), -1)
-
+    response = self.publish(path, '%s:%s' % (self.manager_username,
+                                                        self.manager_password))
+    self.assertNotEquals(response.getBody().find(content), -1)
     # Through a web_section.
     path = web_section.absolute_url_path() + '/NXD-Document.Cache'
-    self.assertNotEquals(request.traverse(path)(REQUEST=request.REQUEST,
-      RESPONSE=request.RESPONSE).find(content), -1)
+    response = self.publish(path, '%s:%s' % (self.manager_username,
+                                                        self.manager_password))
+    self.assertNotEquals(response.getBody().find(content), -1)
 
     # Modify the web_page content
     # Use unrestrictedTraverse (XXX-JPS reason unknown)
@@ -1093,15 +1096,17 @@ H茅 H茅 H茅!""", page.asText().strip())
     web_document = web_section.restrictedTraverse('NXD-Document.Cache')
     self.assertEquals(web_document.asText().strip(), 'modified text')
     path = web_section.absolute_url_path() + '/NXD-Document.Cache'
-    self.assertNotEquals(request.traverse(path)(REQUEST=request.REQUEST,
-      RESPONSE=request.RESPONSE).find(new_content), -1)
+    response = self.publish(path, '%s:%s' % (self.manager_username,
+                                                        self.manager_password))
+    self.assertNotEquals(response.getBody().find(new_content), -1)
 
     # Through a web_site.
     web_document = website.restrictedTraverse('NXD-Document.Cache')
     self.assertEquals(web_document.asText().strip(), 'modified text')
     path = website.absolute_url_path() + '/NXD-Document.Cache'
-    self.assertNotEquals(request.traverse(path)(REQUEST=request.REQUEST,
-      RESPONSE=request.RESPONSE).find(new_content), -1)
+    response = self.publish(path, '%s:%s' % (self.manager_username,
+                                                        self.manager_password))
+    self.assertNotEquals(response.getBody().find(new_content), -1)
 
 
   def test_14_AccessWebSiteForWithDifferentUserPreferences(self):
-- 
2.30.9