Unit test for asserting correct url in list_services

This commit enhances check_service_client_function with a new
arg called ``mock_args`` which can be used to assert that function2mock
was called with args/kwargs passed to ``mock_args``.

A docstring was added to check_service_client_function which includes
information for ``mock_args``:

:param mock_args: List/dict of expected args/kwargs called by
       function2mock. For example: If mock_args=['foo'] then
       ``assert_called_once_with('foo')`` is called. If
       mock_args={'foo': 'bar'} then
       ``assert_called_once_with(foo='bar')`` is called.

This means that more robust service client testing can be performed
to avoid errors in [0] from happening. This approach can also be
extended to not only self.get -- but also to self.post or self.put and
so entire payloads to the clients can be validated via unit testing.

An alternative (but worse) implementation is this:

    @mock.patch.object(services_client, 'urllib')
    def test_list_services_with_params(self, mock_urllib):
        self._test_list_services(type='fake-type')
        mock_urllib.urlencode.assert_called_once_with(
            {'type': 'fake-type'})

but all this does is assert that the params are url-encoded. It does
nothing to assert that self.get, for example, is actually called with
the right URL.

[0] I2e2ebb72732ab95d5f9c1d988037c5e263bf2a71

Change-Id: Ib066add5ff09bd3b32b293833ed6b7a3d5b43955
2 files changed