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
Bryan Kaperick
erp5
Commits
371c0b96
Commit
371c0b96
authored
Dec 05, 2017
by
Roque Porchetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scalability_test: new test suite createScaleOrder
parent
71f28b43
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
234 additions
and
0 deletions
+234
-0
scalability_test/example/createPerson.py
scalability_test/example/createPerson.py
+3
-0
scalability_test/example/createSaleOrder.py
scalability_test/example/createSaleOrder.py
+108
-0
scalability_test/example/utils.py
scalability_test/example/utils.py
+123
-0
No files found.
scalability_test/example/createPerson.py
View file @
371c0b96
...
@@ -8,6 +8,9 @@ TMIN_SLEEP_LONG = 10
...
@@ -8,6 +8,9 @@ TMIN_SLEEP_LONG = 10
TMAX_SLEEP_LONG
=
30
TMAX_SLEEP_LONG
=
30
def
createPerson
(
result
,
browser
):
def
createPerson
(
result
,
browser
):
"""
Create a Person with some details.
"""
# Open ERP5 homepage
# Open ERP5 homepage
browser
.
open
(
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
))
browser
.
open
(
sleep
=
(
TMIN_SLEEP_SHORT
,
TMAX_SLEEP_SHORT
))
...
...
scalability_test/example/createSaleOrder.py
0 → 100755
View file @
371c0b96
# -*- coding: utf-8 -*-
import
datetime
import
random
import
time
import
string
from
utils
import
*
TMIN_SLEEP
=
2
TMAX_SLEEP
=
6
PREFIX_TITLE
=
""
MAX_PRODUCT
=
5
def
addOrderLine
(
browser
,
my_title
,
result
)
:
"""
Add an order line to the sale order
@param browser: Browser
@type browser: Browser
@param my_title: The sale order title
@type my_title: string
"""
# Create a new Sale Order Line
browser
.
mainForm
.
submitSelectAction
(
label
=
"Add Sale Order Line"
)
assert
browser
.
getTransitionMessage
()
==
'Object created.'
# Fill the quantity randomly
browser
.
mainForm
.
getControl
(
name
=
'field_my_quantity'
).
value
=
str
(
random
.
randint
(
1
,
20
))
result
(
'SetRelationProduct'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
assert
browser
.
getTransitionMessage
()
==
'Data updated.'
# Choose the product randomly
fillRelatedObjects
(
browser
,
result
,
"portal_selections/viewSearchRelatedDocumentDialog0:method"
,
1
,
"AddOrderLine"
,
TMIN_SLEEP
,
TMAX_SLEEP
)
def
createSaleOrder
(
result
,
browser
):
"""
Create a Sale Order with details using Sale Trade Condition to fill,
and add some random sale order lines.
"""
# Open ERP5 homepage and log in
result
(
'Open'
,
browser
.
open
())
# Log in unless already logged in by a previous test suite
result
(
'Login'
,
browser
.
mainForm
.
submitLogin
(
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
# Go to sale Order module
result
(
'GotoModule'
,
browser
.
mainForm
.
submitSelectModule
(
value
=
'/sale_order_module'
,
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
# Create a new sale order and record the time elapsed in seconds
result
(
'Create'
,
browser
.
mainForm
.
submitNew
(
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
# Check whether it has been successfully created
assert
browser
.
getTransitionMessage
()
==
'Object created.'
my_order_sale_url
=
browser
.
url
.
split
(
"?"
)[
0
]
# Fill the title
my_title
=
PREFIX_TITLE
+
generateString
(
6
)
browser
.
mainForm
.
getControl
(
name
=
'field_my_title'
).
value
=
my_title
# Set some random informations
my_str
=
generateString
(
random
.
randint
(
1
,
100
))
browser
.
mainForm
.
getControl
(
name
=
'field_my_comment'
).
value
=
my_str
browser
.
mainForm
.
getControl
(
name
=
'field_my_description'
).
value
=
my_str
# Select some options randomly
selectRandomOption
(
browser
,
"field_my_order"
)
# Set dates
date
=
datetime
.
datetime
.
now
()
browser
.
mainForm
.
getControl
(
name
=
'subfield_field_my_start_date_day'
).
value
=
str
(
date
.
day
)
browser
.
mainForm
.
getControl
(
name
=
'subfield_field_my_start_date_month'
).
value
=
str
(
date
.
month
)
browser
.
mainForm
.
getControl
(
name
=
'subfield_field_my_start_date_year'
).
value
=
str
(
date
.
year
)
# Submit the changes, record the time elapsed in seconds
result
(
'Save'
,
browser
.
mainForm
.
submitSave
(
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
# Check whether the changes have been successfully updated
assert
browser
.
getTransitionMessage
()
==
'Data updated.'
sale_order_url
=
browser
.
url
# Set Sale Trade Condition, Client and Beneficiary
for
number_button
in
(
2
,
4
,
5
):
fillRelatedObjects
(
browser
,
result
,
"portal_selections/viewSearchRelatedDocumentDialog%s:method"
%
str
(
number_button
),
1
,
"AddOrderLine"
,
TMIN_SLEEP
,
TMAX_SLEEP
)
# Add Sale order lines
max_ite
=
random
.
randint
(
1
,
MAX_PRODUCT
)
for
i
in
range
(
0
,
max_ite
):
browser
.
open
(
sale_order_url
+
"/view"
)
addOrderLine
(
browser
,
my_title
,
result
)
browser
.
open
(
my_order_sale_url
)
# Validate the Sale Order
browser
.
mainForm
.
submitSelectWorkflow
(
value
=
'plan_action'
)
result
(
'Validate'
,
browser
.
mainForm
.
submitDialogConfirm
(
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
assert
browser
.
getTransitionMessage
()
==
'Status changed.'
\ No newline at end of file
scalability_test/example/utils.py
0 → 100644
View file @
371c0b96
import
random
import
string
def
selectRandomOption
(
browser
,
select_name
):
"""
Function to select randomly an option
@param browser: Browser
@type browser: Browser
@param select_name: Name of the input
@type select_name: string
"""
# Get the option values
options
=
browser
.
mainForm
.
getControl
(
name
=
select_name
).
options
[
1
:]
if
len
(
options
)
>
0
:
# Select randomly one value
browser
.
mainForm
.
getControl
(
name
=
select_name
).
value
=
[
random
.
choice
(
options
)]
def
generateString
(
size
)
:
"""
Function to generate a string randomly (a-z)
@param size: Size of the string
@type size: int
"""
new_string
=
random
.
choice
(
string
.
ascii_uppercase
)
new_string
=
new_string
+
''
.
join
(
random
.
choice
(
string
.
ascii_lowercase
)
for
x
in
range
(
size
))
return
new_string
def
fillRelatedObjects
(
browser
,
result
,
name
,
maximum
=
1
,
actionName
=
""
,
TMIN_SLEEP
=
0
,
TMAX_SLEEP
=
0
,
col_num
=
0
,
text
=
""
)
:
"""
Function to fill randomly related objetcs
@param browser: browser
@type browser: Browser
@param result: result
@type result:
@param name: Name of the input name attribute
@type name: string
@param maximum: Max number of related objects
@type maximum: int
@param actionName: Name of the action (used for backtrace and statistic ?)
@type actionName: string
@param TMIN_SLEEP: Min time to sleep (in second)
@type TMIN_SLEEP: int
@param TMAX_SLEEP: Max time to sleep (in second)
@type TMAX_SLEEP: int
@param col_num: The numero of the column to filter
@type col_num: int
@param text: Text used to filter
@type text: string
"""
# Go to the section linked by the input
result
(
'GoTo '
+
actionName
+
' Relations'
,
browser
.
mainForm
.
getControl
(
name
=
name
).
click
())
# Check the status
assert
((
browser
.
getTransitionMessage
()
==
'Please select one (or more) object.'
)
or
(
browser
.
getTransitionMessage
()
==
'Please select one object.'
))
# Check if it is possible to choose many objects
if
(
browser
.
getTransitionMessage
()
==
'Please select one object.'
):
assert
(
maximum
<=
1
)
# Filter applied the 'col_num' column with text 'text'
if
col_num
!=
0
:
browser
.
mainForm
.
getListboxControl
(
line_number
=
2
,
column_number
=
col_num
).
value
=
text
browser
.
mainForm
.
submitDialogUpdate
()
# Get the number of lines
page_stop_number
=
browser
.
etree
.
xpath
(
'//span[@class="listbox-current-page-stop-number"]'
)
if
len
(
page_stop_number
)
>
0
:
num_line
=
int
(
page_stop_number
[
0
].
text
)
else
:
num_line
=
0
# Choose randomly one or more objects
if
(
num_line
>
0
)
and
(
maximum
>
0
):
iteration
=
random
.
randint
(
1
,
maximum
)
for
i
in
range
(
0
,
iteration
):
line_number
=
random
.
randint
(
1
,
num_line
)
+
2
# Check the box corresponding to line_number if not already checked
if
not
browser
.
mainForm
.
getListboxControl
(
line_number
=
line_number
,
column_number
=
1
).
value
==
'checked'
:
browser
.
mainForm
.
getListboxControl
(
line_number
=
line_number
,
column_number
=
1
).
value
=
'checked'
result
(
'Submit '
+
actionName
+
' Relations'
,
browser
.
mainForm
.
submit
(
name
=
'Base_callDialogMethod:method'
,
sleep
=
(
TMIN_SLEEP
,
TMAX_SLEEP
)))
# Check whether the changes have been successfully updated
assert
browser
.
getTransitionMessage
()
==
'Data updated.'
def
fillOneRelatedObjectSimplified
(
browser
,
name
):
"""
Function to fill randomly related objetcs
@param browser: browser
@type browser: Browser
@param name: Name of the input name attribute
@type name: string
"""
# Go to the section linked by the input
browser
.
mainForm
.
getControl
(
name
=
name
).
click
()
# Check the status
assert
(
browser
.
getTransitionMessage
()
==
'Please select one object.'
)
# Get the number of line
page_stop_number
=
browser
.
etree
.
xpath
(
'//span[@class="listbox-current-page-stop-number"]'
)
if
len
(
page_stop_number
)
>
0
:
num_line
=
int
(
page_stop_number
[
0
].
text
)
else
:
num_line
=
0
# Choose randomly one or more objects
if
num_line
>
0
:
line_number
=
random
.
randint
(
1
,
num_line
)
+
2
# Check the box corresponding to line_number if not already checked
browser
.
mainForm
.
getListboxControl
(
line_number
=
line_number
,
column_number
=
1
).
value
=
'checked'
browser
.
mainForm
.
submit
(
name
=
'Base_callDialogMethod:method'
)
# Check whether the changes have been successfully updated
assert
browser
.
getTransitionMessage
()
==
'Data updated.'
\ No newline at end of file
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