TestCenter Reference
TestSupport.ChangeSet.ChangeSet Class Reference

Class to handle field changes and make them revertable. More...

Inheritance diagram for TestSupport.ChangeSet.ChangeSet:
TestSupport.TestHelper.TC_ChangeSet

Public Member Functions

 __init__ (self, context)
 The default constructor.
 __del__ (self)
 The default destructor.
bool setFieldValue (self, fieldName, fieldValue, verbose=False)
 Set the value of a field.
bool updateFieldValue (self, fieldName, fieldValue, verbose=False)
 Updates the value of a field.
 addField (self, fieldName, verbose=False)
 Add a field and its value without setting it.
 autoRevert (self)
 Revert all changes made if auto-revert is enabled.
 revert (self)
 Revert all changes made.
 enableAutoRevert (self, enable)

Protected Member Functions

 _logInfo (self, message)
 _logError (self, message)

Detailed Description

Class to handle field changes and make them revertable.

The first time a field value is changed the original value is backed up such that it can be restored later on. Restoring will be done at destruction time or using the revert method. It is possible to create a hierarchy of ChangeSets to make interleaved usage possible. It allows to create temporary settings that are reverted to a previous state such that other settings can be used using a basic setting. Each ChangeSet is allowed to have one child only!

Definition at line 29 of file ChangeSet.py.

Constructor & Destructor Documentation

◆ __init__()

TestSupport.ChangeSet.ChangeSet.__init__ ( self,
context )

The default constructor.

Parameters
contextThe context to be used.

Definition at line 42 of file ChangeSet.py.

References __changeDict, __changeStack, TestCenterAdvanced.Slave.Slave.__ctx, __ctx, and __enableAutoRevert.

◆ __del__()

TestSupport.ChangeSet.ChangeSet.__del__ ( self)

The default destructor.

This is where the made changes are reverted if this hasn't happened before

Definition at line 53 of file ChangeSet.py.

References autoRevert().

Member Function Documentation

◆ _logError()

TestSupport.ChangeSet.ChangeSet._logError ( self,
message )
protected

Reimplemented in TestSupport.TestHelper.TC_ChangeSet.

Definition at line 65 of file ChangeSet.py.

Referenced by addField(), setFieldValue(), and updateFieldValue().

◆ _logInfo()

TestSupport.ChangeSet.ChangeSet._logInfo ( self,
message )
protected

Reimplemented in TestSupport.TestHelper.TC_ChangeSet.

Definition at line 59 of file ChangeSet.py.

Referenced by setFieldValue(), and updateFieldValue().

◆ addField()

TestSupport.ChangeSet.ChangeSet.addField ( self,
fieldName,
verbose = False )

Add a field and its value without setting it.

This can be useful for fields that are changed automatically.

Parameters
fieldNameThe name of the field to be added.
verboseBe verbose.
Returns
True if adding field succeeded.

Definition at line 146 of file ChangeSet.py.

References __changeDict, TestCenterAdvanced.Slave.Slave.__ctx, __ctx, _logError(), and TestSupport.ChangeSet.getFieldValue().

◆ autoRevert()

TestSupport.ChangeSet.ChangeSet.autoRevert ( self)

Revert all changes made if auto-revert is enabled.

Definition at line 159 of file ChangeSet.py.

References TestCenterAdvanced.Slave.Slave.__ctx, __ctx, __enableAutoRevert, and revert().

Referenced by __del__().

◆ enableAutoRevert()

TestSupport.ChangeSet.ChangeSet.enableAutoRevert ( self,
enable )

Definition at line 177 of file ChangeSet.py.

References __enableAutoRevert.

◆ revert()

TestSupport.ChangeSet.ChangeSet.revert ( self)

Revert all changes made.

Definition at line 167 of file ChangeSet.py.

References __changeDict, __changeStack, TestCenterAdvanced.Slave.Slave.__ctx, __ctx, and setFieldValue().

Referenced by autoRevert().

◆ setFieldValue()

bool TestSupport.ChangeSet.ChangeSet.setFieldValue ( self,
fieldName,
fieldValue,
verbose = False )

Set the value of a field.

The initial value of the field will be stored such that it can be restored after the required operation have been done.

Parameters
fieldNameThe field to set.
fieldValueThe new value of the given field.
verboseGive information which field was set.
Returns
False if setting field value failed.

Definition at line 78 of file ChangeSet.py.

References __changeDict, __changeStack, TestCenterAdvanced.Slave.Slave.__ctx, __ctx, _logError(), _logInfo(), TestSupport.ChangeSet.getFieldValue(), and setFieldValue().

Referenced by revert(), setFieldValue(), and updateFieldValue().

◆ updateFieldValue()

bool TestSupport.ChangeSet.ChangeSet.updateFieldValue ( self,
fieldName,
fieldValue,
verbose = False )

Updates the value of a field.

If the new value differs from the initial value, the initial value of the field will be stored such that it can be restored after the required operation have been done. If not the field will not even be touched.

Parameters
fieldNameThe field to update.
fieldValueThe new value of the given field.
verboseGive information which field was update.
Returns
False if updating field value failed.

Definition at line 109 of file ChangeSet.py.

References __changeDict, __changeStack, TestCenterAdvanced.Slave.Slave.__ctx, __ctx, _logError(), _logInfo(), TestSupport.ChangeSet.getFieldValue(), and setFieldValue().


The documentation for this class was generated from the following file:
  • MeVisLab/Standard/Modules/Scripts/python/TestSupport/ChangeSet.py