Adventures in unit testing the Basecamp API

I’m working on a little side project, that I might open source once the code is less rough, which involves using the [Basecamp API](

My package uses the [Python wrapper for the API]( and then does some naming convention magic to divine the number of [Sprints and Backlogs][scrum] and generally gives some other useful reporting info.

There are no tests for the wrapper, and I couldn’t sleep at night, let alone [develop software](, without tests.

I started off just using the API and living with the fact that my test suite made network calls to a dummy project I setup in [Basecamp](

But this morning I worked up a clever (I hope) solution — I subclassed the Python wrapper object and hooked up some methods that allow my [TestCase]( to record any network transactions and serialize them down to a fixture file.

When a test is run again the serialized data is used, the network is untouched, and I am a happy camper.

**Update:** The code for the [TestBasecamp object]( has been posted to [Gist](

**Update again:** The entire Basecamp API project, dubbed [BasecampReporting]( has been posted to [GitHub](

The advantages were that:

* I didn’t have to write a complete, or even a partial, implementation of the Basecamp API in Python to provide mock responses
* As I keep going if I need data that hasn’t been serialized yet my test suite will pull it from the dummy project only once and then subsequent tests can use it

It’s probably not the ideal solution, but so far it’s seemed to work for me.


About Chris

Python developer, Agile practitioner trying desperately not to be a pointy haired boss.
This entry was posted in Programming, Python. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s