Commit 500cddcb authored by Nicolas Dumazet's avatar Nicolas Dumazet

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
parent 3befddad
......@@ -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()
......
......@@ -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()
......
......@@ -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()
......
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