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
Leo Le Bouter
erp5
Commits
0903f18e
Commit
0903f18e
authored
Sep 27, 2011
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add randomSleep() function to simulate an user more realistically.
parent
788a154b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
2 deletions
+29
-2
erp5/util/testbrowser/browser.py
erp5/util/testbrowser/browser.py
+29
-2
No files found.
erp5/util/testbrowser/browser.py
View file @
0903f18e
...
@@ -69,6 +69,10 @@ def measurementMetaClass(prefix):
...
@@ -69,6 +69,10 @@ def measurementMetaClass(prefix):
return a tuple with the time spent on the request and the time spent
return a tuple with the time spent on the request and the time spent
on waiting
on waiting
"""
"""
if
'sleep'
in
kwargs
:
minimum_sleep
,
maximum_sleep
=
kwargs
.
pop
(
'sleep'
)
self
.
randomSleep
(
minimum_sleep
,
maximum_sleep
)
ret
=
method
(
self
,
*
args
,
**
kwargs
)
ret
=
method
(
self
,
*
args
,
**
kwargs
)
if
ret
is
None
:
if
ret
is
None
:
return
self
.
lastRequestSeconds
return
self
.
lastRequestSeconds
...
@@ -118,6 +122,9 @@ def measurementMetaClass(prefix):
...
@@ -118,6 +122,9 @@ def measurementMetaClass(prefix):
return
MeasurementMetaClass
return
MeasurementMetaClass
import
random
import
time
class
Browser
(
ExtendedTestBrowser
):
class
Browser
(
ExtendedTestBrowser
):
"""
"""
Implements mechanize tests specific to an ERP5 environment through
Implements mechanize tests specific to an ERP5 environment through
...
@@ -194,6 +201,28 @@ class Browser(ExtendedTestBrowser):
...
@@ -194,6 +201,28 @@ 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
randomSleep
(
self
,
minimum
,
maximum
):
"""
Allow to randomly sleep in seconds in the interval [minimum,
maximum] and is meaningful to simulate an user more realistically.
It is also called automatically when passing sleep argument to
click* (C{Link} classes), submit* (C{Form} classes) or open*
(C{Browser} classes) functions, see C{timeInSecondDecorator} wrapper.
@param minimum: Minimum number of seconds to sleep
@type minimum: int
@param maximum: Maximum number of seconds to sleep
@type maximum: int
"""
sleep_time
=
random
.
randint
(
minimum
,
maximum
)
self
.
_logger
.
debug
(
"Sleeping %ds ([%d, %d])"
%
(
sleep_time
,
minimum
,
maximum
))
time
.
sleep
(
sleep_time
)
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.
...
@@ -734,8 +763,6 @@ class MainForm(Form):
...
@@ -734,8 +763,6 @@ class MainForm(Form):
"""
"""
self
.
submitSelectFavourite
(
value
=
'/logout'
)
self
.
submitSelectFavourite
(
value
=
'/logout'
)
import
time
class
ContextMainForm
(
MainForm
):
class
ContextMainForm
(
MainForm
):
"""
"""
Class defining context-dependent convenient methods for the main
Class defining context-dependent convenient methods for the main
...
...
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