Add unit test for posting samples.

This is just an initial test, using the mock package. Right now, we only
verify the nice code path. Though, it is already useful to spot
regressions.