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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alecs_myu
erp5
Commits
376c1b5f
Commit
376c1b5f
authored
Dec 19, 2016
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unit test: refactor code setting ERP5TypeTestCase user
Also by default this user will have random password
parent
2774123b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
product/ERP5Type/tests/ERP5TypeTestCase.py
product/ERP5Type/tests/ERP5TypeTestCase.py
+20
-8
No files found.
product/ERP5Type/tests/ERP5TypeTestCase.py
View file @
376c1b5f
...
@@ -14,6 +14,7 @@ import os
...
@@ -14,6 +14,7 @@ import os
import
random
import
random
import
re
import
re
import
socket
import
socket
import
string
import
sys
import
sys
import
time
import
time
import
traceback
import
traceback
...
@@ -228,6 +229,18 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
...
@@ -228,6 +229,18 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
"""
"""
return
str
(
self
.
__class__
)
return
str
(
self
.
__class__
)
def
addERP5TypeTestCaseUser
(
self
,
password
=
None
,
user_folder
=
None
):
if
password
is
None
:
password
=
self
.
newPassword
()
if
user_folder
is
None
:
user_folder
=
self
.
portal
.
acl_users
user_folder
.
_doAddUser
(
'ERP5TypeTestCase'
,
password
,
[
'Manager'
,
'Member'
,
'Assignee'
,
'Assignor'
,
'Author'
,
'Auditor'
,
'Associate'
],
[])
def
newPassword
(
self
):
""" Generate a password """
return
''
.
join
(
random
.
SystemRandom
().
sample
(
string
.
letters
+
string
.
digits
,
20
))
def
login
(
self
,
user_name
=
'ERP5TypeTestCase'
,
quiet
=
0
):
def
login
(
self
,
user_name
=
'ERP5TypeTestCase'
,
quiet
=
0
):
"""
"""
Most of the time, we need to login before doing anything
Most of the time, we need to login before doing anything
...
@@ -235,9 +248,7 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
...
@@ -235,9 +248,7 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
try
:
try
:
PortalTestCase
.
login
(
self
,
user_name
)
PortalTestCase
.
login
(
self
,
user_name
)
except
AttributeError
:
except
AttributeError
:
uf
=
self
.
portal
.
acl_users
self
.
addERP5TypeTestCaseUser
()
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
,
'Member'
,
'Assignee'
,
'Assignor'
,
'Author'
,
'Auditor'
,
'Associate'
],
[])
return
PortalTestCase
.
login
(
self
,
user_name
)
return
PortalTestCase
.
login
(
self
,
user_name
)
def
changeSkin
(
self
,
skin_name
):
def
changeSkin
(
self
,
skin_name
):
...
@@ -261,7 +272,7 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
...
@@ -261,7 +272,7 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
uf
=
self
.
portal
.
acl_users
uf
=
self
.
portal
.
acl_users
# do nothing if the user already exists
# do nothing if the user already exists
if
not
uf
.
getUserById
(
user_name
):
if
not
uf
.
getUserById
(
user_name
):
uf
.
_doAddUser
(
user_name
,
'secret'
,
[
'Member'
],
[])
uf
.
_doAddUser
(
user_name
,
self
.
newPassword
()
,
[
'Member'
],
[])
def
_setUpDummyMailHost
(
self
):
def
_setUpDummyMailHost
(
self
):
"""Replace Original Mail Host by Dummy Mail Host in a non-persistent way
"""Replace Original Mail Host by Dummy Mail Host in a non-persistent way
...
@@ -717,6 +728,9 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
...
@@ -717,6 +728,9 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
class
ERP5TypeCommandLineTestCase
(
ERP5TypeTestCaseMixin
):
class
ERP5TypeCommandLineTestCase
(
ERP5TypeTestCaseMixin
):
def
addERP5TypeTestCaseUser
(
self
,
password
=
None
,
**
kw
):
return
super
(
ERP5TypeCommandLineTestCase
,
self
).
addERP5TypeTestCaseUser
(
password
=
''
,
**
kw
)
def
getPortalName
(
self
):
def
getPortalName
(
self
):
"""
"""
Return the name of a portal for this test case.
Return the name of a portal for this test case.
...
@@ -1035,8 +1049,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
...
@@ -1035,8 +1049,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
if
not
quiet
:
if
not
quiet
:
ZopeTestCase
.
_print
(
'Adding ERP5TypeTestCase user ...
\
n
'
)
ZopeTestCase
.
_print
(
'Adding ERP5TypeTestCase user ...
\
n
'
)
uf
=
app
.
acl_users
uf
=
app
.
acl_users
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
,
'Member'
,
'Assignee'
,
self
.
addERP5TypeTestCaseUser
(
user_folder
=
uf
)
'Assignor'
,
'Author'
,
'Auditor'
,
'Associate'
],
[])
user
=
uf
.
getUserById
(
'ERP5TypeTestCase'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'ERP5TypeTestCase'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
newSecurityManager
(
None
,
user
)
...
@@ -1097,8 +1110,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
...
@@ -1097,8 +1110,7 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
self
.
_updateMemcachedConfiguration
()
self
.
_updateMemcachedConfiguration
()
# Create a Manager user at the Portal level
# Create a Manager user at the Portal level
uf
=
self
.
getPortal
().
acl_users
uf
=
self
.
getPortal
().
acl_users
uf
.
_doAddUser
(
'ERP5TypeTestCase'
,
''
,
[
'Manager'
,
'Member'
,
'Assignee'
,
self
.
addERP5TypeTestCaseUser
()
'Assignor'
,
'Author'
,
'Auditor'
,
'Associate'
],
[])
user
=
uf
.
getUserById
(
'ERP5TypeTestCase'
).
__of__
(
uf
)
user
=
uf
.
getUserById
(
'ERP5TypeTestCase'
).
__of__
(
uf
)
self
.
_callSetUpOnce
()
self
.
_callSetUpOnce
()
...
...
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