Permalink
Browse files

Fix Collection.find_one() on PY3K.

Removed unused code.
  • Loading branch information...
1 parent 75e40ee commit f262749269db0a41f59c9924d1d45bd5269b9fea @stefanofontanelli committed Aug 23, 2012
Showing with 5 additions and 21 deletions.
  1. +5 −1 mongobag/mongo.py
  2. +0 −10 tests/test_controllers.py
  3. +0 −10 tests/test_mongo.py
View
@@ -122,7 +122,11 @@ def find_one(self, spec_or_id=None, *args, **kwargs):
if doc is None:
raise NoResultFound('No result for: %s' % spec_or_id)
- return doc
+ if isinstance(doc, Document) or \
+ self._documentClass is None:
+ return doc
+
+ return document_factory(self._documentClass, **doc)
def find(self, spec=None, *args, **kwargs):
View
@@ -5,9 +5,7 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import logging
-import subprocess
import unittest
-#from multiprocessing import Process
from mongobag import Connection
@@ -17,8 +15,6 @@
class TestMongoBase(unittest.TestCase):
def setUp(self):
- #self.mongod = Process(target=self.start_mongo_server)
- #self.mongod.start()
self.connection = Connection(auto_start_request=False)
self.connection.start_request()
self.database_name = 'test'
@@ -28,12 +24,6 @@ def tearDown(self):
self.connection.drop_database(self.database_name)
self.connection.end_request()
self.connection.close()
- #self.mongod.terminate()
-
- def start_mongo_server(self):
- #mongod run --config /usr/local/etc/mongod.conf
- args = ['mongod', 'run', '--config', '/usr/local/etc/mongod.conf']
- subprocess.call(args)
def test_crud(self):
from .model import Account
View
@@ -5,9 +5,7 @@
# the MIT License: http://www.opensource.org/licenses/mit-license.php
import logging
-import subprocess
import unittest
-#from multiprocessing import Process
from mongobag import Connection
from mongobag import NoResultFound
@@ -18,8 +16,6 @@
class TestMongoModule(unittest.TestCase):
def setUp(self):
- #self.mongod = Process(target=self.start_mongo_server)
- #self.mongod.start()
self.connection = None
self.connection = Connection(auto_start_request=False)
self.connection.start_request()
@@ -30,12 +26,6 @@ def tearDown(self):
self.connection.drop_database(self.database_name)
self.connection.end_request()
self.connection.close()
- #self.mongod.terminate()
-
- def start_mongo_server(self):
- #mongod run --config /usr/local/etc/mongod.conf
- args = ['mongod', 'run', '--config', '/usr/local/etc/mongod.conf']
- subprocess.call(args)
def test_insert(self):
from .model import Account

0 comments on commit f262749

Please sign in to comment.