Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
erp5
Commits
9af1ae70
Commit
9af1ae70
authored
Sep 09, 2011
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't log in automatically to be able to run test suites as anonymous user for example
parent
7e9642a6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
32 deletions
+24
-32
erp5/util/benchmark/examples/createPerson.py
erp5/util/benchmark/examples/createPerson.py
+3
-0
erp5/util/testbrowser/browser.py
erp5/util/testbrowser/browser.py
+19
-31
erp5/util/testbrowser/examples/createPerson.py
erp5/util/testbrowser/examples/createPerson.py
+2
-1
No files found.
erp5/util/benchmark/examples/createPerson.py
View file @
9af1ae70
...
@@ -12,6 +12,9 @@ def createPerson(result, browser):
...
@@ -12,6 +12,9 @@ def createPerson(result, browser):
script and userInfo.py. Further information about performance_tester_erp5
script and userInfo.py. Further information about performance_tester_erp5
options and arguments are available by specifying ``--help''.
options and arguments are available by specifying ``--help''.
"""
"""
# Log in unless already logged in by a previous test suite
browser
.
mainForm
.
submitLogin
()
# Go to Persons module (person_module)
# Go to Persons module (person_module)
result
(
'Go to person module'
,
result
(
'Go to person module'
,
browser
.
mainForm
.
submitSelectModule
(
value
=
'/person_module'
))
browser
.
mainForm
.
submitSelectModule
(
value
=
'/person_module'
))
...
...
erp5/util/testbrowser/browser.py
View file @
9af1ae70
...
@@ -182,8 +182,6 @@ class Browser(ExtendedTestBrowser):
...
@@ -182,8 +182,6 @@ class Browser(ExtendedTestBrowser):
super
(
Browser
,
self
).
__init__
()
super
(
Browser
,
self
).
__init__
()
self
.
login
()
def
open
(
self
,
url_or_path
=
None
,
data
=
None
):
def
open
(
self
,
url_or_path
=
None
,
data
=
None
):
"""
"""
Open a relative (to the ERP5 base URL) or absolute URL. If the
Open a relative (to the ERP5 base URL) or absolute URL. If the
...
@@ -200,27 +198,6 @@ class Browser(ExtendedTestBrowser):
...
@@ -200,27 +198,6 @@ class Browser(ExtendedTestBrowser):
self
.
_logger
.
debug
(
"Opening url: "
+
absolute_url
)
self
.
_logger
.
debug
(
"Opening url: "
+
absolute_url
)
super
(
Browser
,
self
).
open
(
absolute_url
,
data
)
super
(
Browser
,
self
).
open
(
absolute_url
,
data
)
def
login
(
self
,
force
=
False
):
"""
Log in only if not already logged in unless explicitely specified
to do so.
@param force: Log in even if already logged in
@type force: bool
"""
if
force
or
not
self
.
_is_logged_in
:
try
:
url_before_login
=
self
.
url
except
:
url_before_login
=
None
self
.
open
(
'login_form'
)
self
.
mainForm
.
submitLogin
()
# Go back to the page before trying to log in if any URL, or to
# the homepage otherwise
self
.
open
(
url_before_login
)
def
getCookieValue
(
self
,
name
,
default
=
None
):
def
getCookieValue
(
self
,
name
,
default
=
None
):
"""
"""
Get the cookie value of the given cookie name.
Get the cookie value of the given cookie name.
...
@@ -685,22 +662,35 @@ class MainForm(Form):
...
@@ -685,22 +662,35 @@ class MainForm(Form):
"""
"""
Log into ERP5 using the username and password provided in the
Log into ERP5 using the username and password provided in the
browser. It is assumed that the current page is the login page (by
browser. It is assumed that the current page is the login page (by
calling C{open('login_form')} beforehand).
calling C{open('login_form')} beforehand), otherwise it will open
that page before logging in.
This method should rarely be used by scripts as login is already
Note that if the user is already logged in, it will do nothing.
performed upon instanciation of Browser class.
@raise LoginError: Login failed
@raise LoginError: Login failed
@todo: Use information sent back as headers rather than looking
@todo: Use information sent back as headers rather than looking
into the page content?
into the page content?
"""
"""
if
'Logged In as'
in
self
.
browser
.
contents
:
self
.
browser
.
_logger
.
debug
(
"Already logged in"
)
# TODO: Perhaps zope.testbrowser should be patched instead?
self
.
browser
.
timer
.
start_time
=
self
.
browser
.
timer
.
end_time
=
0
return
self
.
browser
.
_logger
.
debug
(
"Logging in: username='%s', password='%s'"
%
\
self
.
browser
.
_logger
.
debug
(
"Logging in: username='%s', password='%s'"
%
\
(
self
.
browser
.
_username
,
self
.
browser
.
_password
))
(
self
.
browser
.
_username
,
self
.
browser
.
_password
))
self
.
getControl
(
name
=
'__ac_name'
).
value
=
self
.
browser
.
_username
def
login
(
form
):
self
.
getControl
(
name
=
'__ac_password'
).
value
=
self
.
browser
.
_password
form
.
getControl
(
name
=
'__ac_name'
).
value
=
self
.
browser
.
_username
self
.
submit
()
form
.
getControl
(
name
=
'__ac_password'
).
value
=
self
.
browser
.
_password
form
.
submit
()
try
:
login
(
self
)
except
LookupError
:
self
.
browser
.
open
(
'login_form'
)
login
(
self
.
browser
.
mainForm
)
if
'Logged In as'
not
in
self
.
browser
.
contents
:
if
'Logged In as'
not
in
self
.
browser
.
contents
:
raise
LoginError
(
"%s: Could not log in as '%s:%s'"
%
\
raise
LoginError
(
"%s: Could not log in as '%s:%s'"
%
\
...
@@ -708,8 +698,6 @@ class MainForm(Form):
...
@@ -708,8 +698,6 @@ class MainForm(Form):
self
.
browser
.
_username
,
self
.
browser
.
_username
,
self
.
browser
.
_password
))
self
.
browser
.
_password
))
self
.
browser
.
_is_logged_in
=
True
def
submitSelectFavourite
(
self
,
label
=
None
,
value
=
None
,
**
kw
):
def
submitSelectFavourite
(
self
,
label
=
None
,
value
=
None
,
**
kw
):
"""
"""
Select and submit a favourite, given either by its label (such as
Select and submit a favourite, given either by its label (such as
...
...
erp5/util/testbrowser/examples/createPerson.py
View file @
9af1ae70
...
@@ -13,8 +13,9 @@ def benchmarkAddPerson(iteration_counter, result_dict):
...
@@ -13,8 +13,9 @@ def benchmarkAddPerson(iteration_counter, result_dict):
browser
=
Browser
(
'http://localhost:18080/'
,
'erp5'
,
browser
=
Browser
(
'http://localhost:18080/'
,
'erp5'
,
username
=
'zope'
,
password
=
'zope'
)
username
=
'zope'
,
password
=
'zope'
)
# Open ERP5 homepage
# Open ERP5 homepage
and log in
browser
.
open
()
browser
.
open
()
browser
.
mainForm
.
submitLogin
()
# Go to Persons module (person_module)
# Go to Persons module (person_module)
browser
.
mainForm
.
submitSelectModule
(
value
=
'/person_module'
)
browser
.
mainForm
.
submitSelectModule
(
value
=
'/person_module'
)
...
...
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