The Command class is what underlies the add_command() methods on MockSession and other Container classes.
Command instances are used to make assertions about API function calls and their arguments.
The Command class is what underlies the add_command() methods on MockSession and other Container classes.
Command instances are used to make assertions about API function calls and their arguments.
Command inherits from the SingleState and State base classes (in that order) and conforms to the protocols defined by both.
This page details only areas where Command extends or deviates from those protocols.
The Command() constructor takes three arguments, two of which are optional.
Command(svn.core.apr_initialize)
Command(svn.core.svn_create_pool, (None,))
Command(svn.fs.youngest_rev, (fs, apr_pool), 7)
The first parameter is the function object to be checked against.
It will be compared with the incoming API function call using is.
The second parameter is optional. It is used to specify the arguments that the API function should be passed; any iterable may be used for this. If this is left unspecified, the default is to assert that the function should be called without arguments.
The third parameter is optional.
It is used to specify the return value from the API function call.
If this is left unspecified, the default is to return an instance of the Return class.
The Return instance will be built around the first and second parameter to the Command() constructor.
Command.__call__ conforms to the SingleState protocol.
If the incoming API function call validates, Command.__call__ will return the return value specified to the Command() constructor when the instance was created.
When a Command instance is called (Command.__call__) the next() method of the instance's container will be invoked regardless of whether or not the API call validated successfully or not.