Commit 55ca5028 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Add erp5.utils.test_browser which is supposed to deprecate

ERP5Mechanize soonish



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44707 20353a03-c40f-0410-a6d1-a30d3c3de9de
parents
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
API Documentation
-----------------
You can generate the API documentation using ``epydoc'':
$ epydoc -v src/erp5
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
This diff is collapsed.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from erp5.utils.test_browser.browser import Browser
ITERATION = 20
def benchmarkAddPerson(result_dict):
"""
Benchmark adding a person
"""
# Create a browser instance
browser = Browser('http://localhost:18080/', 'erp5', username='zope', password='zope')
# Open ERP5 homepage
browser.open()
# Go to Persons module (person_module)
browser.mainForm.submitSelectModule(label='Persons')
# Create a new person and record the time elapsed in seconds
result_dict.setdefault('Create new person', []).append(browser.mainForm.secondSubmitNew())
# Check whether it has been successfully created
assert browser.getTransitionMessage() == 'Object created.'
# Fill the first and last name of the newly created person
browser.mainForm.getControl(name='field_my_first_name').value = 'Foo'
browser.mainForm.getControl(name='field_my_last_name').value = 'Bar'
# Submit the changes, record the time elapsed in seconds
result_dict.setdefault('Save', []).append(browser.mainForm.secondSubmitSave())
# Check whether the changes have been successfully updated
assert browser.getTransitionMessage() == 'Data updated.'
# Validate the person and record confirmation
browser.mainForm.submitSelectWorkflow(label='Validate')
result_dict.setdefault('Validate', []).append(browser.mainForm.secondSubmitDialogConfirm())
# Check whether it has been successfully validated
assert browser.getTransitionMessage() == 'Status changed.'
if __name__ == '__main__':
# Run benchmarkAddPerson ITERATION times and compute the average time it
# took for each operation
result_dict = {}
counter = 0
while counter != ITERATION:
benchmarkAddPerson(result_dict)
counter += 1
for title, time_list in result_dict.iteritems():
print "Average: %s: %.4fs" % (title, float(sum(time_list)) / ITERATION)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment