From 9b3fe09508e6bd5fc7fe8ed6fff97f515841bede Mon Sep 17 00:00:00 2001 From: Erdenezul Date: Fri, 18 Aug 2017 09:31:26 +0800 Subject: [PATCH] added as_pymongo test for PointField #1311 --- tests/queryset/geo.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/queryset/geo.py b/tests/queryset/geo.py index 51a32382..38c0377e 100644 --- a/tests/queryset/geo.py +++ b/tests/queryset/geo.py @@ -510,6 +510,24 @@ class GeoQueriesTest(MongoDBTestCase): roads = Road.objects.filter(poly__geo_intersects={"$geometry": polygon}).count() self.assertEqual(1, roads) + def test_aspymongo_with_only(self): + """Ensure as_pymongo works with only""" + class Place(Document): + location = PointField() + + Place.drop_collection() + p = Place(location=[24.946861267089844, 60.16311983618494]) + p.save() + qs = Place.objects().only('location') + self.assertDictEqual( + qs.as_pymongo()[0]['location'], + {u'type': u'Point', + u'coordinates': [ + 24.946861267089844, + 60.16311983618494] + } + ) + def test_2dsphere_point_sets_correctly(self): class Location(Document): loc = PointField()