From 500cddcb42d3f48f789f463042606ee7884032c1 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Mon, 19 Oct 2009 15:27:19 +0000 Subject: [PATCH] Use ERP5TestCase.login instead of local methods. Drop unused changeToPreviousUser method git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@29805 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/tests/testNotificationMessageModule.py | 11 +---------- product/ERP5/tests/testNotificationTool.py | 6 ++---- product/ERP5/tests/testPDM.py | 13 ++++--------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/product/ERP5/tests/testNotificationMessageModule.py b/product/ERP5/tests/testNotificationMessageModule.py index 8ac867e801..0e925f6875 100644 --- a/product/ERP5/tests/testNotificationMessageModule.py +++ b/product/ERP5/tests/testNotificationMessageModule.py @@ -56,15 +56,6 @@ class TestNotificationMessageModule(ERP5TypeTestCase): user_folder = self.getPortal().acl_users user_folder._doAddUser(name, 'password', role_list, []) - def changeUser(self, name): - self.old_user = getSecurityManager().getUser() - user_folder = self.getPortal().acl_users - user = user_folder.getUserById(name).__of__(user_folder) - newSecurityManager(None, user) - - def changeToPreviousUser(self): - newSecurityManager(None, self.old_user) - def afterSetUp(self): self.createUser('erp5user', ['Auditor', 'Author']) self.createUser('manager', ['Manager']) @@ -76,7 +67,7 @@ class TestNotificationMessageModule(ERP5TypeTestCase): self.portal.portal_caches.clearAllCache() transaction.commit() self.tic() - self.changeUser('erp5user') + self.login('erp5user') def beforeTearDown(self): transaction.abort() diff --git a/product/ERP5/tests/testNotificationTool.py b/product/ERP5/tests/testNotificationTool.py index 265d688010..79ed6503f2 100644 --- a/product/ERP5/tests/testNotificationTool.py +++ b/product/ERP5/tests/testNotificationTool.py @@ -114,9 +114,7 @@ class TestNotificationTool(ERP5TypeTestCase): def changeUser(self, name): self.old_user = getSecurityManager().getUser() - user_folder = self.getPortal().acl_users - user = user_folder.getUserById(name).__of__(user_folder) - newSecurityManager(None, user) + self.login(name) def changeToPreviousUser(self): newSecurityManager(None, self.old_user) @@ -132,7 +130,7 @@ class TestNotificationTool(ERP5TypeTestCase): self.portal.portal_caches.clearAllCache() transaction.commit() self.tic() - self.changeUser('erp5user') + self.login('erp5user') def beforeTearDown(self): transaction.abort() diff --git a/product/ERP5/tests/testPDM.py b/product/ERP5/tests/testPDM.py index 16afe5a233..0392ebd5ec 100644 --- a/product/ERP5/tests/testPDM.py +++ b/product/ERP5/tests/testPDM.py @@ -61,16 +61,11 @@ class TestPDMWithSecurity(ERP5TypeTestCase): transaction.commit() self.tic() - def changeUser(self, name): - user_folder = self.getPortal().acl_users - user = user_folder.getUserById(name).__of__(user_folder) - newSecurityManager(None, user) - def testValidatedProductCanContainMeasure(self): """ Make sure that validated product can contain measure. """ - self.changeUser('author') + self.login('author') product = self.portal.product_module.newContent(portal_type='Product', title='Chair') @@ -85,7 +80,7 @@ class TestPDMWithSecurity(ERP5TypeTestCase): self.assertEqual(len(product.contentValues(portal_type='Measure')), 1) - self.changeUser('assignor') + self.login('assignor') self.portal.portal_workflow.doActionFor(product, 'validate_action') transaction.commit() @@ -94,12 +89,12 @@ class TestPDMWithSecurity(ERP5TypeTestCase): self.assertEqual(product.getValidationState(), 'validated') # Change to author and try to add a measure to validated product and fail. - self.changeUser('author') + self.login('author') self.assertRaises(AccessControl_Unauthorized, product.newContent, portal_type='Measure') # Change to assignee and try to add a measure to validated product and succeed. - self.changeUser('assignee') + self.login('assignee') product.newContent(portal_type='Measure') transaction.commit() -- 2.30.9