Skip to content

according to the docs, this should be a 404 #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ _build
.coverage
dist
*.pyc
.pytest_cache/

.idea
.idea
2 changes: 1 addition & 1 deletion flask_pymongo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def to_python(self, value):
try:
return ObjectId(value)
except InvalidId:
raise abort(400)
raise abort(404)

def to_url(self, value):
return str(value)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_url_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
from flask_pymongo import BSONObjectIdConverter

from bson import ObjectId
from werkzeug.exceptions import BadRequest
from werkzeug.exceptions import NotFound

class UrlConverterTest(FlaskPyMongoTest):

def test_bson_object_id_converter(self):
converter = BSONObjectIdConverter("/")

self.assertRaises(BadRequest, converter.to_python, ("132"))
self.assertRaises(NotFound, converter.to_python, ("132"))
assert converter.to_python("4e4ac5cfffc84958fa1f45fb") == \
ObjectId("4e4ac5cfffc84958fa1f45fb")
assert converter.to_url(ObjectId("4e4ac5cfffc84958fa1f45fb")) == \
Expand Down