sourcefabric/Airtime — pull request #6 by rgrinberg (2012-10-30 04:43:23+00:00)
Title: Api client refactor

First part of api_client refactoring. I've separated all the config and
url plumbing from api client itself into a separate class that's called
RequestProvider. This class isn't really for other modules to use, only
ApiClient itself. RequestProvider is initialized like so:

```
rp = RequestProvider(ConfigObj('api_client.cfg'))
```

Now rp automatically reads every api client method definitions so that you can
call actions defined in api_client.cfg like so:

```
response = rp.notify_webstream_data(media_id=123)
# the method above was automatically inferred from api_client.cfg
notify_webstream_data = 'notify-webstream-data/api_key/%%api_key%%/media_id/%%media_id%%/format/json'
```

Rewriting ApiClient using RequestProvider is going to shorten the code
quite a bit and get rid of all the boilerplate. This will also make
testing ApiClient very easy as well as all we'll have to do is to pass
a fake(mock) RequestProvider to ApiClient that will let introspect
ApiClient's behaviour. See for example tests/test_requiestprovider.py