Re: How do I test a function that calls a web API?

2013-05-03 Thread Vineet Naik
Hi Mike, you can use the mock[1] library for this. [1]: http://www.voidspace.org.uk/python/mock/ On Fri, May 3, 2013 at 11:09 AM, Mike wrote: > I'm starting to write tests for my Django project but I'm not sure how to > test a function that calls out to a web API. I

Re: How do I test a function that calls a web API?

2013-05-03 Thread Russell Keith-Magee
Hi Mike, I can see two options. Option 1: factor the external service API calls behind some sort of interface that can be swapped out at runtime. However, this means a lot of extra work if the interface will only be used for testing. Option 2: look into using Mock [1] [1]

How do I test a function that calls a web API?

2013-05-02 Thread Mike
I'm starting to write tests for my Django project but I'm not sure how to test a function that calls out to a web API. I read somewhere that I should not test against the live web api and that I should develop some sort of replacement for the actual web api server which sounds like a lot of