pulp/pulp — pull request #379 by jdob (2013-03-14 20:42:25+00:00)
Title: PollingCommand refactoring and pulp_devel package

First batch of changes to support polling on async operations such as copy and remove units. This is the base class back end that they will build on, so in theory those changes should be trivial with all of the heavy lifting handled by these changes.

The changes to PollingCommand itself focus around the following:
* Added support for a list of tasks instead of a single task
* Fixed the poll workflow to be standalone; the subclass no longer needs to explicitly check for rejected or postponed on its own
* Postponed tasks will still be polled; other than the displayed message, behaviorally there's no reason to treat waiting and postponed differently (postponed is a specialized version of waiting)
* Removed the resource from the overridden message methods to allow use in non-resource specific operations (e.g. orphan clean up). These methods now just take the task which should provide the resource information anyway.
* Changed the progress reporting method to take the entire task, not just the progress report

There were no unit tests for PollingCommand so I had to create a way to simulate the progression of a task from waiting up to completion. This is implemented in a class called TaskSimulator which allows the dev to set up one or more tasks and their state transitions and then substitute into the bindings task API to replace the live call.

That simulator was needed for the RPM tests, which led down the rabbit hole of how to share testing utilities between projects. We decided on a new python package called pulp_devel in the root of the platform repo. It currently just contains the task simulator and we can move stuff in as we encounter it. This request contains that structure and the unit tests for TaskSimulator, which I think is bizarrely neat that there's tests for the test utilities.

The bulk of the remaining changes are to the commands that already subclassed this to fit in the new API. Common changes:
* Changing calls into poll to take a list of tasks instead of a single task
* Changing the signature of message rendering overridden methods to only take the task; not a single one was using the resource ID anyway, so it was just a signature change
* Removing the calls to postponed() and rejected() as abort clauses before beginning polling. The rejected check is done inside of poll

The pulp_rpm repo also subclassed PollingTask and there will be a pull request in there to do concurrently.