Commit 70420c75 authored by Jérome Perrin's avatar Jérome Perrin

access_token: simplify transaction management in tests

also update _createPerson to reindex, as said in the docstring
parent f923090b
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import transaction
class TestERP5AccessTokenSkins(ERP5TypeTestCase):
......@@ -19,10 +18,8 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
"""
This is ran before anything, used to set the environment
"""
self.portal = self.getPortalObject()
self.new_id = self.generateNewId()
self._setupAccessTokenExtraction()
transaction.commit()
self.tic()
def _setupAccessTokenExtraction(self):
......@@ -38,7 +35,7 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
self.test_token_extraction_id = access_extraction_list[0].getId()
elif len(access_extraction_list) > 1:
raise ValueError
transaction.commit()
self.commit()
def _createPerson(self, new_id):
"""Creates a person in person module, and returns the object, after
......@@ -47,7 +44,7 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
person = person_module.newContent(portal_type='Person',
user_id='TESTP-' + new_id)
person.newContent(portal_type = 'Assignment').open()
transaction.commit()
self.tic()
return person
def _getTokenCredential(self, request):
......
......@@ -32,7 +32,6 @@ from ZPublisher.HTTPRequest import HTTPRequest
from ZPublisher.HTTPResponse import HTTPResponse
from Products.ERP5Security.ERP5DumbHTTPExtractionPlugin import ERP5DumbHTTPExtractionPlugin
import base64
import transaction
import StringIO
class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
......@@ -50,10 +49,8 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
"""
This is ran before anything, used to set the environment
"""
self.portal = self.getPortalObject()
self.new_id = self.generateNewId()
self._setupDumbHTTPExtraction()
transaction.commit()
self.tic()
def do_fake_request(self, request_method, headers=None):
......@@ -90,7 +87,7 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
self.test_id = access_extraction_list[0].getId()
elif len(access_extraction_list) > 1:
raise ValueError
transaction.commit()
self.commit()
def _createPerson(self, new_id, password=None):
"""Creates a person in person module, and returns the object, after
......@@ -101,7 +98,7 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
if password:
person.setPassword(password)
person.newContent(portal_type = 'Assignment').open()
transaction.commit()
self.tic()
return person
def test_working_authentication(self):
......
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