dropbox/responses — pull request #22 by ryaanwells (2014-07-08 21:38:44+00:00)
Title: Explicit Error Mocking

Custom exception can be thrown when requesting a mocked endpoint.

Previously, only a "ConnectionError" could be thrown and only through not setting up an expected url in the specific test case. This isn't a clear way of describing a test (the information of which url is missing and then raising the exception isn't included in the test) and it does not handle other exceptions that Requests can raise (see http://docs.python-requests.org/en/latest/api/?highlight=exception#exceptions)

This pull request allows a custom exception to be raised when a specific url is requested. In a given test it should now be clear what url call is responsible for raising exception, allowing for more exact branch control.

It is achieved by passing an exception instance to the responses.add() call using the "throw_exception" parameter. When a request is made, the exception instance is raised if it exists otherwise the mocking runs as normal.

I'm open to feedback and suggestions!

Thanks, Ryan