pyfarm/pyfarm-master — pull request #119 by opalmer (2014-03-16 06:14:43+00:00)
Title: Add search capabilities necessary for the agent to either create or update its own definition

This change includes a couple of new feature, bugfixes, and some api improvements. The goal here was the give the agent the ability to search for itself more easily without requiring as many `GET` requests. A full list of changes are below and this change also makes the progress necessary to implement the agent side changes for pyfarm/pyfarm-agent#16.

* Add url arguments to `/api/v1/agents/` for `hostname`, `port`, and `ip`. This was needed so the agent can search for itself using a `GET` request before deciding what to do.
* Includes the above url arguments in the resulting output. This is was also required so that if there are multiple entries for the same hostname there's enough unique information to make sense of it on the agent without another `GET` request.
* Changed the output for a search to return `None` and `NOT_FOUND` if no hosts matching the query are discovered.
* Split out most of the url parameter tests for `/api/v1/agents` into individual tests
* Added `assert_contents_equal` to the base test class. This is used to make sure that two iterables contain the same data without caring about order. This was done instead of using sort each time since we don't particularly care about order.
* Added the `get_request_argument` utility function. This is similiar to `request.args.get` except it can produce an error message if we get an unexpected type in a url argument.
* Moved from `datetime.now` -> `datetime.utcnow` in the mixin responsible for setting `time_finished` and `time_started`. The tests for this was passing on travis but was flaky on my local host, this change fixes that flakiness without breaking the tests on travis.