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
60f45986
Commit
60f45986
authored
Jul 16, 2013
by
Benjamin Blanc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
benchmarks: Improve createPerson and createWebPage
parent
647f991e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
106 additions
and
24 deletions
+106
-24
erp5/util/benchmark/examples/createPerson.py
erp5/util/benchmark/examples/createPerson.py
+19
-8
erp5/util/benchmark/examples/createWebPage.py
erp5/util/benchmark/examples/createWebPage.py
+87
-16
No files found.
erp5/util/benchmark/examples/createPerson.py
View file @
60f45986
# -*- coding: utf-8 -*-
TMIN_SLEEP_SHORT
=
0
# 2
TMAX_SLEEP_SHORT
=
0
# 6
TMIN_SLEEP
=
0
# 5
TMAX_SLEEP
=
0
# 15
TMIN_SLEEP_LONG
=
0
# 10
TMAX_SLEEP_LONG
=
0
# 30
def
createPerson
(
result
,
browser
):
"""
Create a Person and add a telephone number. It can be ran infinitely (e.g.
...
...
@@ -21,15 +29,15 @@ def createPerson(result, browser):
instance).
"""
# Open ERP5 homepage
browser
.
open
(
sleep
=
(
0
,
0
))
browser
.
open
(
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
))
# Log in unless already logged in by a previous test suite
browser
.
mainForm
.
submitLogin
(
sleep
=
(
0
,
0
))
browser
.
mainForm
.
submitLogin
(
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
))
# Go to Persons module (person_module)
result
(
'Go to person module'
,
browser
.
mainForm
.
submitSelectModule
(
value
=
'/person_module'
,
sleep
=
(
0
,
0
)))
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
)))
# Create a new person and record the time elapsed in seconds
result
(
'Add Person'
,
browser
.
mainForm
.
submitNew
())
...
...
@@ -40,11 +48,12 @@ def createPerson(result, browser):
# Fill the first and last name of the newly created person
browser
.
mainForm
.
getControl
(
name
=
'field_my_first_name'
).
value
=
'Create'
browser
.
mainForm
.
getControl
(
name
=
'field_my_last_name'
).
value
=
'Person'
# Link to organisation, this will add subobjects
browser
.
mainForm
.
getControl
(
name
=
'field_my_career_subordination_title'
).
value
=
'Supplier'
#
browser.mainForm.getControl(name='field_my_career_subordination_title').value = 'Supplier'
# Submit the changes, record the time elapsed in seconds
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
0
,
0
)))
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
# Check whether the changes have been successfully updated
assert
browser
.
getTransitionMessage
()
==
'Data updated.'
...
...
@@ -53,14 +62,14 @@ def createPerson(result, browser):
# Add phone number
result
(
'Add telephone'
,
browser
.
mainForm
.
submitSelectAction
(
value
=
'add Telephone'
,
sleep
=
(
0
,
0
)))
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
)))
# Fill telephone title and number
browser
.
mainForm
.
getControl
(
name
=
'field_my_title'
).
value
=
'Personal'
browser
.
mainForm
.
getControl
(
name
=
'field_my_telephone_number'
).
value
=
'0123456789'
# Submit the changes, record the time elapsed in seconds
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
0
,
0
)))
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
)))
# Check whether the changes have been successfully updated
assert
browser
.
getTransitionMessage
()
==
'Data updated.'
...
...
@@ -74,9 +83,11 @@ def createPerson(result, browser):
browser
.
mainForm
.
submitSelectWorkflow
(
value
=
'validate_action'
,
maximum_attempt_number
=
5
,
sleep_between_attempt
=
5
,
sleep
=
(
0
,
0
))
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
))
result
(
'Waiting for validate_action'
,
waiting_for_validate_action
)
result
(
'Show validate'
,
show_validate_time
)
result
(
'Validated'
,
browser
.
mainForm
.
submitDialogConfirm
())
assert
browser
.
getTransitionMessage
()
==
'Status changed.'
print
"OK"
erp5/util/benchmark/examples/createWebPage.py
View file @
60f45986
# -*- coding: utf-8 -*-
import
datetime
import
random
import
time
import
string
import
genericToolToFillForm
from
genericToolToFillForm
import
*
PREFIX_TITLE
=
""
if
False
:
TMIN_SLEEP_SHORT
=
0
# 2
TMAX_SLEEP_SHORT
=
0
# 6
TMIN_SLEEP
=
0
# 5
TMAX_SLEEP
=
0
# 15
TMIN_SLEEP_LONG
=
0
# 10
TMAX_SLEEP_LONG
=
0
# 30
NUMMAX_FOLLOW_UP
=
0
NUMMAX_CONTRIBUTORS
=
0
else
:
TMIN_SLEEP_SHORT
=
2
TMAX_SLEEP_SHORT
=
6
TMIN_SLEEP
=
5
TMAX_SLEEP
=
15
TMIN_SLEEP_LONG
=
10
TMAX_SLEEP_LONG
=
30
NUMMAX_FOLLOW_UP
=
1
NUMMAX_CONTRIBUTORS
=
2
def
createWebPage
(
result
,
browser
):
"""
Create a minimal web page with some content & submit it
Note : you need your user to have Assignor role to do workflow transition
you must select the source code editor (plain text) on the preference
"""
# Open ERP5 homepage
browser
.
open
(
sleep
=
(
2
,
6
))
browser
.
open
(
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
))
# Log in unless already logged in by a previous test suite
browser
.
mainForm
.
submitLogin
(
sleep
=
(
2
,
6
))
browser
.
mainForm
.
submitLogin
(
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
))
# Go to WebPage module (person_module)
result
(
'Go to Web Page module'
,
browser
.
mainForm
.
submitSelectModule
(
value
=
'/web_page_module'
,
sleep
=
(
2
,
6
)))
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
)))
# Create a new person and record the time elapsed in seconds
result
(
'Add Web Page'
,
browser
.
mainForm
.
submitNew
())
...
...
@@ -23,42 +55,81 @@ def createWebPage(result, browser):
assert
browser
.
getTransitionMessage
()
==
'Object created.'
# Fill the form
browser
.
mainForm
.
getControl
(
name
=
'field_my_title'
).
value
=
'Web Page Bench'
browser
.
mainForm
.
getControl
(
name
=
'field_my_title'
).
value
=
PREFIX_TITLE
+
'Web Page Bench'
browser
.
mainForm
.
getControl
(
name
=
'field_my_short_title'
).
value
=
'test'
browser
.
mainForm
.
getControl
(
name
=
'field_my_reference'
).
value
=
'001'
browser
.
mainForm
.
getControl
(
name
=
'field_my_version'
).
value
=
"001"
browser
.
mainForm
.
getControl
(
name
=
'field_my_language'
).
value
=
'en'
browser
.
mainForm
.
getControl
(
name
=
'field_my_int_index'
).
value
=
'10'
browser
.
mainForm
.
getControl
(
name
=
'field_my_description'
).
value
=
'Benchmark test'
date
=
datetime
.
datetime
.
now
()
browser
.
mainForm
.
getControl
(
name
=
'subfield_field_my_effective_date_day'
).
value
=
str
(
date
.
day
)
browser
.
mainForm
.
getControl
(
name
=
'subfield_field_my_effective_date_month'
).
value
=
str
(
date
.
month
)
browser
.
mainForm
.
getControl
(
name
=
'subfield_field_my_effective_date_year'
).
value
=
str
(
date
.
year
)
select_random_option
(
browser
,
"subfield_field_my_publication_section_list_default:list"
)
browser
.
mainForm
.
getControl
(
name
=
'field_my_description'
).
value
=
'Benchmark test'
select_random_option
(
browser
,
"field_my_classification"
)
select_random_option
(
browser
,
"subfield_field_my_group_list_default:list"
)
select_random_option
(
browser
,
"subfield_field_my_site_list_default:list"
)
select_random_option
(
browser
,
"subfield_field_my_function_list_default:list"
)
browser
.
mainForm
.
getControl
(
name
=
'field_my_subject_list'
).
value
=
gen_string
(
30
)
## Fill the Follow-up input
fill_related_objects
(
browser
,
result
,
"portal_selections/viewSearchRelatedDocumentDialog0:method"
,
NUMMAX_FOLLOW_UP
,
"FollowUp"
,
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
)
## Fill the Contributors input
fill_related_objects
(
browser
,
result
,
"portal_selections/viewSearchRelatedDocumentDialog1:method"
,
NUMMAX_CONTRIBUTORS
,
"Contributors"
,
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
)
# Submit the changes, record the time elapsed in seconds
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
5
,
15
)))
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
# Check whether the changes have been successfully updated
assert
browser
.
getTransitionMessage
()
==
'Data updated.'
WebPage_url
=
browser
.
url
## Edit the relations with other existing documents
# Go to the Related Documents view
browser
.
open
(
WebPage_url
+
"/Document_viewRelated"
)
# Fill the Referenced Documents input
fill_related_objects
(
browser
,
result
,
"portal_selections/viewSearchRelatedDocumentDialog0:method"
,
3
,
"ReferencedDocument"
,
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
)
# Fill the Similar Documents input
fill_related_objects
(
browser
,
result
,
"portal_selections/viewSearchRelatedDocumentDialog1:method"
,
3
,
" SimilarDocuments"
,
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
)
# Fill the Related Documents input
#fill_related_objects(browser, result,
# "portal_selections/viewSearchRelatedDocumentDialog2:method", 3,
# "RelatedDocuments", TMIN_SLEEP_SHORT, TMAX_SLEEP_SHORT)
# Edit content
#
#
Edit content
WebPage_url
=
'/'
.
join
(
WebPage_url
.
split
(
'/'
)[:
-
1
])
browser
.
open
(
WebPage_url
+
"/WebPage_viewEditor"
)
browser
.
mainForm
.
getControl
(
name
=
'field_my_text_content'
).
value
=
'<html><body><h1>Test</h1><p>Content
i
f test</p></body></html>'
browser
.
mainForm
.
getControl
(
name
=
'field_my_text_content'
).
value
=
'<html><body><h1>Test</h1><p>Content
o
f test</p></body></html>'
# Submit the changes, record the time elapsed in seconds
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
10
,
30
)))
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
TMIN_SLEEP_LONG
,
TMAX_SLEEP_LONG
)))
# Check whether the changes have been successfully updated
assert
browser
.
getTransitionMessage
()
==
'Data updated.'
# Publish it
show_publish_time
,
waiting_for_publish_action
=
\
browser
.
mainForm
.
submitSelectWorkflow
(
value
=
'
publish
_action'
,
browser
.
mainForm
.
submitSelectWorkflow
(
value
=
'
submit
_action'
,
maximum_attempt_number
=
5
,
sleep_between_attempt
=
5
,
sleep
=
(
2
,
6
))
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
))
result
(
'Waiting for publish_action'
,
waiting_for_publish_action
)
result
(
'Show publish'
,
show_publish_time
)
result
(
'Published'
,
browser
.
mainForm
.
submitDialogConfirm
())
# Check whether the changes have been successfully updated
assert
browser
.
getTransitionMessage
()
==
'Status changed.'
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