The State base class is the common superclass to all other State classes in svnmock.
It defines the following protocol:
-
Subclasses of
Statemust define a__call__method. This method, which is used to validate API calls, will accept three required parameters, not including theselfparameter. The first parameter will be the state's Container. The second parameter will be afunction-type object representing the API function that was called. The third parameter will be a tuple of the arguments passed to the function (the second parameter) in the course of the API call.The subclass may choose to either forward this validation request to another
Stateinstance or handle the request itself.When the instance has exhausted its ability to validate further states, it must invoke the
next()method of the object passed in for the second parameter to__call__. -
Subclasses of
Statemust define either an__eq__method or a__ne__method, depending on which is more efficient for that class. It is not necessary to define both; the other will be filled it automatically. -
Subclasses of
Statemust define a__len__method. This method should return the number of API calls the invocant can handle before being exhausted.For example, instances of the Command and Error classes always return 1.
-
Subclasses of
Statemust define aclonemethod. This method take only theselfparameter and return a deep copy of the invocant. -
Subclasses of
Statemust define aresetmethod. This method takes only theselfparameter and should perform whatever operations are necessary to "rewind" the invocant to its initial state.That is, a freshly-created instance should be indistinguishable from an instance whose
resetmethod has been called. -
Subclasses of
Statemust define afreezemethod. This method takes only theselfparameter and should return an instance of FrozenState that thaws to an identical shallow copy of the original invocant.