Commit dfc31234 authored by Arnaud Fontaine's avatar Arnaud Fontaine

Rename second* and pystone* to time*InSecond and time*InPystone respectively


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44765 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 55ca5028
...@@ -49,43 +49,44 @@ def measurementMetaClass(prefix): ...@@ -49,43 +49,44 @@ def measurementMetaClass(prefix):
""" """
class MeasurementMetaClass(type): class MeasurementMetaClass(type):
""" """
Meta class to define automatically C{second*} and C{pystone*} Meta class to define automatically C{time*InSecond} and
methods automatically according to given C{prefix}, and also to C{time*InPystone} methods automatically according to given
define C{lastRequestSeconds} and C{lastRequestPystones} on other C{prefix}, and also to define C{lastRequestSeconds} and
classes besides of Browser. C{lastRequestPystones} on other classes besides of Browser.
""" """
def __new__(metacls, name, bases, dictionary): def __new__(metacls, name, bases, dictionary):
def applyMeasure(method): def applyMeasure(method):
""" """
Inner function to add the C{second} and C{pystone} methods to Inner function to add the C{time*InSecond} and C{time*InPystone}
the dictionary of newly created class. methods to the dictionary of newly created class.
For example, if the method name is C{submitSave} then For example, if the method name is C{submitSave} then
C{secondSubmitSave} and C{pystoneSubmitSave} will be added to C{timeSubmitSaveInSecond} and C{timeSubmitSaveInPystone} will
the newly created class. be added to the newly created class.
@param method: Instance method to be called @param method: Instance method to be called
@type method: function @type method: function
""" """
# Upper the first character # Upper the first character
method_name_suffix = method.func_name[0].upper() + method.func_name[1:] method_name_prefix = 'time' + method.func_name[0].upper() + \
method.func_name[1:]
def innerSecond(self, *args, **kwargs): def innerSecond(self, *args, **kwargs):
method(self, *args, **kwargs) method(self, *args, **kwargs)
return self.lastRequestSeconds return self.lastRequestSeconds
innerSecond.func_name = 'second' + method_name_suffix innerSecond.func_name = method_name_prefix + 'InSecond'
dictionary[innerSecond.func_name] = innerSecond dictionary[innerSecond.func_name] = innerSecond
def innerPystone(self, *args, **kwargs): def innerPystone(self, *args, **kwargs):
method(self, *args, **kwargs) method(self, *args, **kwargs)
return self.lastRequestPystones return self.lastRequestPystones
innerPystone.func_name = 'pystone' + method_name_suffix innerPystone.func_name = method_name_prefix + 'InPystone'
dictionary[innerPystone.func_name] = innerPystone dictionary[innerPystone.func_name] = innerPystone
# Create second* and pystone* methods only for the methods # Create time*InSecond and time*InPystone methods only for the
# prefixed by the given prefix # methods prefixed by the given prefix
for attribute_name, attribute in dictionary.items(): for attribute_name, attribute in dictionary.items():
if attribute_name.startswith(prefix) and callable(attribute): if attribute_name.startswith(prefix) and callable(attribute):
applyMeasure(attribute) applyMeasure(attribute)
......
...@@ -19,7 +19,7 @@ def benchmarkAddPerson(result_dict): ...@@ -19,7 +19,7 @@ def benchmarkAddPerson(result_dict):
browser.mainForm.submitSelectModule(label='Persons') browser.mainForm.submitSelectModule(label='Persons')
# Create a new person and record the time elapsed in seconds # Create a new person and record the time elapsed in seconds
result_dict.setdefault('Create new person', []).append(browser.mainForm.secondSubmitNew()) result_dict.setdefault('Create new person', []).append(browser.mainForm.timeSubmitNewInSecond())
# Check whether it has been successfully created # Check whether it has been successfully created
assert browser.getTransitionMessage() == 'Object created.' assert browser.getTransitionMessage() == 'Object created.'
...@@ -29,14 +29,14 @@ def benchmarkAddPerson(result_dict): ...@@ -29,14 +29,14 @@ def benchmarkAddPerson(result_dict):
browser.mainForm.getControl(name='field_my_last_name').value = 'Bar' browser.mainForm.getControl(name='field_my_last_name').value = 'Bar'
# Submit the changes, record the time elapsed in seconds # Submit the changes, record the time elapsed in seconds
result_dict.setdefault('Save', []).append(browser.mainForm.secondSubmitSave()) result_dict.setdefault('Save', []).append(browser.mainForm.timeSubmitSaveInSecond())
# Check whether the changes have been successfully updated # Check whether the changes have been successfully updated
assert browser.getTransitionMessage() == 'Data updated.' assert browser.getTransitionMessage() == 'Data updated.'
# Validate the person and record confirmation # Validate the person and record confirmation
browser.mainForm.submitSelectWorkflow(label='Validate') browser.mainForm.submitSelectWorkflow(label='Validate')
result_dict.setdefault('Validate', []).append(browser.mainForm.secondSubmitDialogConfirm()) result_dict.setdefault('Validate', []).append(browser.mainForm.timeSubmitDialogConfirmInSecond())
# Check whether it has been successfully validated # Check whether it has been successfully validated
assert browser.getTransitionMessage() == 'Status changed.' assert browser.getTransitionMessage() == 'Status changed.'
......
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