Updates to imports for future pymongo 2.2

This commit is contained in:
Ross Lawley
2012-02-17 11:18:25 +00:00
parent a15352a4f8
commit a59b518cf2
9 changed files with 81 additions and 69 deletions

View File

@@ -4,7 +4,7 @@ import pymongo
import mongoengine.connection
from mongoengine import *
from mongoengine.connection import get_db, get_connection
from mongoengine.connection import get_db, get_connection, ConnectionError
class ConnectionTest(unittest.TestCase):
@@ -33,6 +33,15 @@ class ConnectionTest(unittest.TestCase):
def test_connect_uri(self):
"""Ensure that the connect() method works properly with uri's
"""
c = connect(db='mongoenginetest', alias='admin')
c.admin.system.users.remove({})
c.mongoenginetest.system.users.remove({})
c.admin.add_user("admin", "password")
c.admin.authenticate("admin", "password")
c.mongoenginetest.add_user("username", "password")
self.assertRaises(ConnectionError, connect, "testdb_uri_bad", host='mongodb://test:password@localhost/mongoenginetest')
connect("testdb_uri", host='mongodb://username:password@localhost/mongoenginetest')

View File

@@ -1,5 +1,6 @@
import pickle
import pymongo
import bson
import unittest
import warnings
@@ -2222,7 +2223,7 @@ class DocumentTest(unittest.TestCase):
# Test laziness
self.assertTrue(isinstance(post_obj._data['author'],
pymongo.dbref.DBRef))
bson.DBRef))
self.assertTrue(isinstance(post_obj.author, self.Person))
self.assertEqual(post_obj.author.name, 'Test User')

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import unittest
import pymongo
from bson import ObjectId
from datetime import datetime, timedelta
from mongoengine.queryset import (QuerySet, QuerySetManager,
@@ -59,8 +60,7 @@ class QuerySetTest(unittest.TestCase):
self.assertEqual(len(people), 2)
results = list(people)
self.assertTrue(isinstance(results[0], self.Person))
self.assertTrue(isinstance(results[0].id, (pymongo.objectid.ObjectId,
str, unicode)))
self.assertTrue(isinstance(results[0].id, (ObjectId, str, unicode)))
self.assertEqual(results[0].name, "User A")
self.assertEqual(results[0].age, 20)
self.assertEqual(results[1].name, "User B")