softlayer/softlayer-python — pull request #436 by sudorandom (2014-11-03 01:33:49+00:00)
Title: Pluggable Transports

This makes transports plugable. Things converted to transports:
* SoftLayer.API.TimedClient -> SoftLayer.transports.TimingTransport - Simplifies the implemtation of timing API calls
* SoftLayer.fixture_client.FixtureClient -> FixtureTransport - simplifies the implementation of fixturing a client
* CliClient -> /dev/null
* SoftLayer.transports.make_xml_rpc_api_call -> SoftLayer.transports.XmlRpcTransport - the default transport
* SoftLayer.transports.make_rest_api_call -> SoftLayer.transports.RestTransport - the transport used to hit the metadata service (potentially default in the future)
* SoftLayer.testing.MockableTransport - Adds ability to mock specific API endpoints.

The interface for a transport is a callable which takes SoftLayer.transport.Request as the only argument.
As part of this change, calls(), assert_called_with() and set_mock() methods were added to the TestCase class
in order to help mock and test. The previous way of mocking relied on the fact that the callable returned
with client['SERVICE'].METHOD was also a mock object. This can't be the case with the way transports are
implemented, so this required updating nearly every test.

calls(service_name, method_name) - returns all calls matching the service and method name (both arguments are optional).
assert_called_with(service_name, method_name, **attribs) - attribs correspond to SoftLayer.transports.Request object.
set_mock(service_name, method_name) - returns a mock object which will be called whenever the test client calls that service/method.

This should resolve #435 and #435