Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
138
Merge Requests
138
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
70420c75
Commit
70420c75
authored
Feb 26, 2019
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
access_token: simplify transaction management in tests
also update _createPerson to reindex, as said in the docstring
parent
f923090b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
10 deletions
+4
-10
bt5/erp5_access_token/TestTemplateItem/portal_components/test.erp5.testERP5AccessTokenSkins.py
...m/portal_components/test.erp5.testERP5AccessTokenSkins.py
+2
-5
bt5/erp5_access_token/TestTemplateItem/portal_components/test.erp5.testERP5DumbHTTPExtractionPlugin.py
..._components/test.erp5.testERP5DumbHTTPExtractionPlugin.py
+2
-5
No files found.
bt5/erp5_access_token/TestTemplateItem/portal_components/test.erp5.testERP5AccessTokenSkins.py
View file @
70420c75
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
# Copyright (c) 2002-2013 Nexedi SA and Contributors. All Rights Reserved.
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
import
transaction
class
TestERP5AccessTokenSkins
(
ERP5TypeTestCase
):
class
TestERP5AccessTokenSkins
(
ERP5TypeTestCase
):
...
@@ -19,10 +18,8 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
...
@@ -19,10 +18,8 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
"""
"""
This is ran before anything, used to set the environment
This is ran before anything, used to set the environment
"""
"""
self
.
portal
=
self
.
getPortalObject
()
self
.
new_id
=
self
.
generateNewId
()
self
.
new_id
=
self
.
generateNewId
()
self
.
_setupAccessTokenExtraction
()
self
.
_setupAccessTokenExtraction
()
transaction
.
commit
()
self
.
tic
()
self
.
tic
()
def
_setupAccessTokenExtraction
(
self
):
def
_setupAccessTokenExtraction
(
self
):
...
@@ -38,7 +35,7 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
...
@@ -38,7 +35,7 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
self
.
test_token_extraction_id
=
access_extraction_list
[
0
].
getId
()
self
.
test_token_extraction_id
=
access_extraction_list
[
0
].
getId
()
elif
len
(
access_extraction_list
)
>
1
:
elif
len
(
access_extraction_list
)
>
1
:
raise
ValueError
raise
ValueError
transaction
.
commit
()
self
.
commit
()
def
_createPerson
(
self
,
new_id
):
def
_createPerson
(
self
,
new_id
):
"""Creates a person in person module, and returns the object, after
"""Creates a person in person module, and returns the object, after
...
@@ -47,7 +44,7 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
...
@@ -47,7 +44,7 @@ class TestERP5AccessTokenSkins(ERP5TypeTestCase):
person
=
person_module
.
newContent
(
portal_type
=
'Person'
,
person
=
person_module
.
newContent
(
portal_type
=
'Person'
,
user_id
=
'TESTP-'
+
new_id
)
user_id
=
'TESTP-'
+
new_id
)
person
.
newContent
(
portal_type
=
'Assignment'
).
open
()
person
.
newContent
(
portal_type
=
'Assignment'
).
open
()
transaction
.
commit
()
self
.
tic
()
return
person
return
person
def
_getTokenCredential
(
self
,
request
):
def
_getTokenCredential
(
self
,
request
):
...
...
bt5/erp5_access_token/TestTemplateItem/portal_components/test.erp5.testERP5DumbHTTPExtractionPlugin.py
View file @
70420c75
...
@@ -32,7 +32,6 @@ from ZPublisher.HTTPRequest import HTTPRequest
...
@@ -32,7 +32,6 @@ from ZPublisher.HTTPRequest import HTTPRequest
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
ZPublisher.HTTPResponse
import
HTTPResponse
from
Products.ERP5Security.ERP5DumbHTTPExtractionPlugin
import
ERP5DumbHTTPExtractionPlugin
from
Products.ERP5Security.ERP5DumbHTTPExtractionPlugin
import
ERP5DumbHTTPExtractionPlugin
import
base64
import
base64
import
transaction
import
StringIO
import
StringIO
class
TestERP5DumbHTTPExtractionPlugin
(
ERP5TypeTestCase
):
class
TestERP5DumbHTTPExtractionPlugin
(
ERP5TypeTestCase
):
...
@@ -50,10 +49,8 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
...
@@ -50,10 +49,8 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
"""
"""
This is ran before anything, used to set the environment
This is ran before anything, used to set the environment
"""
"""
self
.
portal
=
self
.
getPortalObject
()
self
.
new_id
=
self
.
generateNewId
()
self
.
new_id
=
self
.
generateNewId
()
self
.
_setupDumbHTTPExtraction
()
self
.
_setupDumbHTTPExtraction
()
transaction
.
commit
()
self
.
tic
()
self
.
tic
()
def
do_fake_request
(
self
,
request_method
,
headers
=
None
):
def
do_fake_request
(
self
,
request_method
,
headers
=
None
):
...
@@ -90,7 +87,7 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
...
@@ -90,7 +87,7 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
self
.
test_id
=
access_extraction_list
[
0
].
getId
()
self
.
test_id
=
access_extraction_list
[
0
].
getId
()
elif
len
(
access_extraction_list
)
>
1
:
elif
len
(
access_extraction_list
)
>
1
:
raise
ValueError
raise
ValueError
transaction
.
commit
()
self
.
commit
()
def
_createPerson
(
self
,
new_id
,
password
=
None
):
def
_createPerson
(
self
,
new_id
,
password
=
None
):
"""Creates a person in person module, and returns the object, after
"""Creates a person in person module, and returns the object, after
...
@@ -101,7 +98,7 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
...
@@ -101,7 +98,7 @@ class TestERP5DumbHTTPExtractionPlugin(ERP5TypeTestCase):
if
password
:
if
password
:
person
.
setPassword
(
password
)
person
.
setPassword
(
password
)
person
.
newContent
(
portal_type
=
'Assignment'
).
open
()
person
.
newContent
(
portal_type
=
'Assignment'
).
open
()
transaction
.
commit
()
self
.
tic
()
return
person
return
person
def
test_working_authentication
(
self
):
def
test_working_authentication
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment