Merge pull request #1626 from erdenezul/pointfield_aspymongo
added as_pymongo test for PointField #1311
This commit is contained in:
commit
0325a62f18
@ -510,6 +510,24 @@ class GeoQueriesTest(MongoDBTestCase):
|
|||||||
roads = Road.objects.filter(poly__geo_intersects={"$geometry": polygon}).count()
|
roads = Road.objects.filter(poly__geo_intersects={"$geometry": polygon}).count()
|
||||||
self.assertEqual(1, roads)
|
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):
|
def test_2dsphere_point_sets_correctly(self):
|
||||||
class Location(Document):
|
class Location(Document):
|
||||||
loc = PointField()
|
loc = PointField()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user