Merge pull request #1025 from MRigal/feature/259-improve-error-detection-for-invalid-query

Improve error message for invalid query
This commit is contained in:
Matthieu Rigal
2015-06-12 09:13:18 +02:00
3 changed files with 17 additions and 3 deletions

View File

@@ -224,6 +224,15 @@ class TransformTest(unittest.TestCase):
self.assertEqual(1, Doc.objects(item__type__="axe").count())
self.assertEqual(1, Doc.objects(item__name__="Heroic axe").count())
def test_understandable_error_raised(self):
class Event(Document):
title = StringField()
location = GeoPointField()
box = [(35.0, -125.0), (40.0, -100.0)]
# I *meant* to execute location__within_box=box
events = Event.objects(location__within=box)
self.assertRaises(InvalidQueryError, lambda: events.count())
if __name__ == '__main__':
unittest.main()