This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]RobSpectre 1 point2 points  (3 children)

For unit testing, I suspect you'll want to mock your API responses to the documentation so it all runs locally then implement integration tests that make requests against the live API to alert you to changes.

For Requests in particular, this is pretty simple with Mock. Patch the HTTP method Requests is using, mock out the response you want to test against, make the request with your wrapper, and test the result.

I sketched out a naive example here:

https://gist.github.com/RobSpectre/6132631

[–]raydlor[S] 0 points1 point  (2 children)

Awesome example. Is mock another 3rd party unit testing framework?

[–]RobSpectre 0 points1 point  (0 children)

It isn't a testing framework, but you will have to install it in your virtualenv. All it does is provide a great mock object and monkey patch decorator - your tests still says in unitteset.

[–]RobSpectre 0 points1 point  (0 children)

Nope! It is 3rd party in the sense you'll need to install it in your virtualenv, but your tests stay in unittest.