diff --git a/.install_mongodb_on_travis.sh b/.install_mongodb_on_travis.sh index 8563ae744..f2018411e 100644 --- a/.install_mongodb_on_travis.sh +++ b/.install_mongodb_on_travis.sh @@ -1,5 +1,6 @@ #!/bin/bash +sudo apt-get remove mongodb-org-server sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 if [ "$MONGODB" = "2.4" ]; then @@ -13,7 +14,7 @@ elif [ "$MONGODB" = "2.6" ]; then sudo apt-get install mongodb-org-server=2.6.12 # service should be started automatically elif [ "$MONGODB" = "3.0" ]; then - echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list + echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list sudo apt-get update sudo apt-get install mongodb-org-server=3.0.14 # service should be started automatically @@ -21,3 +22,6 @@ else echo "Invalid MongoDB version, expected 2.4, 2.6, or 3.0." exit 1 fi; + +mkdir db +1>db/logs mongod --dbpath=db & diff --git a/.travis.yml b/.travis.yml index 8f846ab1f..5e90660d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,8 @@ matrix: before_install: - bash .install_mongodb_on_travis.sh +- sleep 15 # https://docs.travis-ci.com/user/database-setup/#MongoDB-does-not-immediately-accept-connections +- mongo --eval 'db.version();' install: - sudo apt-get install python-dev python3-dev libopenjpeg-dev zlib1g-dev libjpeg-turbo8-dev diff --git a/tests/queryset/geo.py b/tests/queryset/geo.py index 51a323821..38c0377ed 100644 --- a/tests/queryset/geo.py +++ b/tests/queryset/geo.py @@ -510,6 +510,24 @@ class Road(Document): 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()