nicolaiarocci/eve — pull request #278 by boosh (2014-03-09 10:54:17+00:00)
Title: Return a 400 response on pymongo DuplicateKeyError

Note: This is a cleaned up version of #268 that isn't directly on develop.

Duplicate key errors were returning 500s. Now they return a more precise 400 instead (409 would be the most accurate, but I see you're reraising errors as 400s - search for "# consider all other exceptions as Bad Requests". Perhaps this is to avoid leaking too much information?)

Re tests: I'd normally test this by using `mock` to mock the return value of the call to `self.driver.db[datasource].update` to raise a `pymongo.errors.DuplicateKeyError`, but you don't seem to be using mock. I can't see any existing tests for the update method... is it OK if I introduce mock as a dependency? If not, how would you like this testing?