cots.mock – Mocking Product Handlers¶
This module is a mocking product handler to test the lapptrack module or any
python module using the cots package.
This module differs from the dummy module, because the latter exists as an example (more precisely as a skeleton) to implement a product handler.
Public Classes¶
This module includes a number of handlers listed below in alphabetical order.
A mocking handler is a derived class from the BaseMockHandler class.
Objects reference¶
This section details the objects defined in this module.
- class cots.mock.BaseMockHandler¶
Bases:
cots.core.BaseProductCommon base class for mocking handler.
This class is a base class for mocking handler used to test the
lapptrackmodule or any python module using thecotspackage. Most of information about handler mechanism are in thecots.coremodule and more particularly in theBaseProductclass documentation.- Overridden Methods
This class is a concrete class, so the overridden methods are listed below in alphabetical order.
- dump()¶
Dump the handler class attributes.
The method use a variable named
attributesto store a copy of public attributes. Theattributescontent may be altered by the script.- Returns
Contain a copy of the instance variables values.
- Return type
- fetch(dirpath)¶
Download the mocking installer.
- is_update(product)¶
Return if this instance is an update.
This method compare the version of the two product, and return the comparison result. The version numbers used by the editor are compliant with the semantic versioning specification 2.0.0 (see
support.semvermodule)- Parameters
product (BaseProduct) – The reference product (i.e. the deployed one)
- Returns
Trueif this instance is an update of the product specified by theproductparameter.- Return type
- load(attributes=None)¶
Load the saved handler class attributes.
- class cots.mock.MockHandler¶
Bases:
cots.mock.BaseMockHandlerMocking handler.
This concrete class implements a mocking handler used to test the
lapptrackmodule or any python module using thecotspackage. Most of information about handler mechanism are in thecots.coreand more particularly in theBaseProductclass documentation.
- class cots.mock.BrotherMockHandler¶
Bases:
cots.mock.BaseMockHandlerMocking handler.
This concrete class implements a mocking handler (similar to
MockHandler) used to test thelapptrackmodule or any python module using thecotspackage.
- class cots.mock.FailureMockHandler¶
Bases:
cots.mock.BaseMockHandlerFailure mocking handler.
This concrete class implements a mocking handler used to test the
lapptrackmodule or any python module using thecotspackage. This handler always return an error on thefetchorget_originmethod call. In this context,is_updatemethod should not be called so his call raise anRuntimeErrorexception.- Overridden Methods
This class is a concrete class, so the overridden methods are listed below in alphabetical order.
- fetch(dirpath)¶
Download the mocking installer.
This method always return
Falseto indicate that an error has occurred while the product installer fetching.
- get_origin()¶
Get the mocking information.
This method always return
Falseto indicate that an error has occurred while the fetching of the product information.- Returns
always False.
- Return type
- is_update(product)¶
Return if this instance is an update.
In this context, this method should not be called.
- Parameters
product (BaseProduct) – The reference product (i.e. the deployed one)
- Raises
RuntimeError – see above.
- class cots.mock.ErrorMockHandler¶
Bases:
cots.mock.BaseMockHandlerError mocking handler.
This concrete class implements a mocking handler used to test the
lapptrackmodule or any python module using thecotspackage. This handler raises anTypeErrorexception on thefetchorget_originmethod call. In this context,is_updatemethod should not be called so his call raise anRuntimeErrorexception.- Overridden Methods
This class is a concrete class, so the overridden methods are listed below in alphabetical order.
- get_origin()¶
Get the mocking information.
This method always raises an
TypeErrorexception.- Raises
TypeError – see above.
- is_update(product)¶
Return if this instance is an update.
In this context, this method should not be called.
- Parameters
product (BaseProduct) – The reference product (i.e. the deployed one)
- Raises
RuntimeError – see above.