Skip to content

Commit 1b558cc

Browse files
committed
Merge branch 'categulario-raise-404'
2 parents 133640a + 79905ab commit 1b558cc

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ _build
55
.coverage
66
dist
77
*.pyc
8+
.pytest_cache/
89

9-
.idea
10+
.idea

flask_pymongo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def to_python(self, value):
8181
try:
8282
return ObjectId(value)
8383
except InvalidId:
84-
raise abort(400)
84+
raise abort(404)
8585

8686
def to_url(self, value):
8787
return str(value)

tests/test_url_converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
from flask_pymongo import BSONObjectIdConverter
33

44
from bson import ObjectId
5-
from werkzeug.exceptions import BadRequest
5+
from werkzeug.exceptions import NotFound
66

77
class UrlConverterTest(FlaskPyMongoTest):
88

99
def test_bson_object_id_converter(self):
1010
converter = BSONObjectIdConverter("/")
1111

12-
self.assertRaises(BadRequest, converter.to_python, ("132"))
12+
self.assertRaises(NotFound, converter.to_python, ("132"))
1313
assert converter.to_python("4e4ac5cfffc84958fa1f45fb") == \
1414
ObjectId("4e4ac5cfffc84958fa1f45fb")
1515
assert converter.to_url(ObjectId("4e4ac5cfffc84958fa1f45fb")) == \

0 commit comments

Comments
 (0)