Updated tests
This commit is contained in:
parent
f182daa85e
commit
0cbd3663e4
@ -3,7 +3,8 @@ This test has been put into a module. This is because it tests warnings that
|
|||||||
only get triggered on first hit. This way we can ensure its imported into the
|
only get triggered on first hit. This way we can ensure its imported into the
|
||||||
top level and called first by the test suite.
|
top level and called first by the test suite.
|
||||||
"""
|
"""
|
||||||
|
import sys
|
||||||
|
sys.path[0:0] = [""]
|
||||||
import unittest
|
import unittest
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
@ -88,3 +89,6 @@ class AllWarnings(unittest.TestCase):
|
|||||||
self.assertEqual(SyntaxWarning, warning["category"])
|
self.assertEqual(SyntaxWarning, warning["category"])
|
||||||
self.assertEqual('non_abstract_base',
|
self.assertEqual('non_abstract_base',
|
||||||
InheritedDocumentFailTest._get_collection_name())
|
InheritedDocumentFailTest._get_collection_name())
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path[0:0] = [""]
|
@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
import sys
|
||||||
|
sys.path[0:0] = [""]
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from mongoengine import *
|
from mongoengine import *
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path[0:0] = [""]
|
sys.path[0:0] = [""]
|
||||||
|
|
||||||
from mongoengine import *
|
from mongoengine import *
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import unittest
|
import unittest
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path[0:0] = [""]
|
sys.path[0:0] = [""]
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import sys
|
||||||
|
sys.path[0:0] = [""]
|
||||||
import unittest
|
import unittest
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ class ValidatorErrorTest(unittest.TestCase):
|
|||||||
except ValidationError, e:
|
except ValidationError, e:
|
||||||
self.assertTrue("SubDoc:None" in e.message)
|
self.assertTrue("SubDoc:None" in e.message)
|
||||||
self.assertEqual(e.to_dict(), {
|
self.assertEqual(e.to_dict(), {
|
||||||
'e.val': 'Field is required'})
|
"e": {'val': 'OK could not be converted to int'}})
|
||||||
|
|
||||||
Doc.drop_collection()
|
Doc.drop_collection()
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class ValidatorErrorTest(unittest.TestCase):
|
|||||||
except ValidationError, e:
|
except ValidationError, e:
|
||||||
self.assertTrue("Doc:test" in e.message)
|
self.assertTrue("Doc:test" in e.message)
|
||||||
self.assertEqual(e.to_dict(), {
|
self.assertEqual(e.to_dict(), {
|
||||||
'e.val': 'Field is required'})
|
"e": {'val': 'OK could not be converted to int'}})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import datetime
|
import sys
|
||||||
import pymongo
|
sys.path[0:0] = [""]
|
||||||
import unittest
|
import unittest
|
||||||
|
import datetime
|
||||||
|
|
||||||
import mongoengine.connection
|
import pymongo
|
||||||
|
|
||||||
from bson.tz_util import utc
|
from bson.tz_util import utc
|
||||||
|
|
||||||
from mongoengine import *
|
from mongoengine import *
|
||||||
|
import mongoengine.connection
|
||||||
from mongoengine.connection import get_db, get_connection, ConnectionError
|
from mongoengine.connection import get_db, get_connection, ConnectionError
|
||||||
from mongoengine.context_managers import switch_db
|
from mongoengine.context_managers import switch_db
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
import sys
|
||||||
|
sys.path[0:0] = [""]
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from mongoengine import *
|
from mongoengine import *
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import sys
|
import sys
|
||||||
sys.path[0:0] = [""]
|
sys.path[0:0] = [""]
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bson import DBRef, ObjectId
|
from bson import DBRef, ObjectId
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
import sys
|
||||||
|
sys.path[0:0] = [""]
|
||||||
import unittest
|
import unittest
|
||||||
from nose.plugins.skip import SkipTest
|
from nose.plugins.skip import SkipTest
|
||||||
from mongoengine.python_support import PY3
|
from mongoengine.python_support import PY3
|
||||||
@ -163,3 +165,6 @@ class MongoDBSessionTest(SessionTestsMixin, unittest.TestCase):
|
|||||||
key = session.session_key
|
key = session.session_key
|
||||||
session = SessionStore(key)
|
session = SessionStore(key)
|
||||||
self.assertTrue('test_expire' in session, 'Session has expired before it is expected')
|
self.assertTrue('test_expire' in session, 'Session has expired before it is expected')
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import sys
|
||||||
|
sys.path[0:0] = [""]
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import pymongo
|
import pymongo
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import sys
|
||||||
|
sys.path[0:0] = [""]
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from mongoengine import *
|
from mongoengine import *
|
||||||
@ -21,6 +23,7 @@ class SignalTests(unittest.TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
connect(db='mongoenginetest')
|
connect(db='mongoenginetest')
|
||||||
|
|
||||||
class Author(Document):
|
class Author(Document):
|
||||||
name = StringField()
|
name = StringField()
|
||||||
|
|
||||||
@ -70,7 +73,6 @@ class SignalTests(unittest.TestCase):
|
|||||||
signal_output.append('Not loaded')
|
signal_output.append('Not loaded')
|
||||||
self.Author = Author
|
self.Author = Author
|
||||||
|
|
||||||
|
|
||||||
class Another(Document):
|
class Another(Document):
|
||||||
name = StringField()
|
name = StringField()
|
||||||
|
|
||||||
@ -122,8 +124,8 @@ class SignalTests(unittest.TestCase):
|
|||||||
|
|
||||||
self.ExplicitId = ExplicitId
|
self.ExplicitId = ExplicitId
|
||||||
self.ExplicitId.objects.delete()
|
self.ExplicitId.objects.delete()
|
||||||
# Save up the number of connected signals so that we can check at the end
|
# Save up the number of connected signals so that we can check at the
|
||||||
# that all the signals we register get properly unregistered
|
# end that all the signals we register get properly unregistered
|
||||||
self.pre_signals = (
|
self.pre_signals = (
|
||||||
len(signals.pre_init.receivers),
|
len(signals.pre_init.receivers),
|
||||||
len(signals.post_init.receivers),
|
len(signals.post_init.receivers),
|
||||||
@ -192,7 +194,7 @@ class SignalTests(unittest.TestCase):
|
|||||||
""" Model saves should throw some signals. """
|
""" Model saves should throw some signals. """
|
||||||
|
|
||||||
def create_author():
|
def create_author():
|
||||||
a1 = self.Author(name='Bill Shakespeare')
|
self.Author(name='Bill Shakespeare')
|
||||||
|
|
||||||
def bulk_create_author_with_load():
|
def bulk_create_author_with_load():
|
||||||
a1 = self.Author(name='Bill Shakespeare')
|
a1 = self.Author(name='Bill Shakespeare')
|
||||||
@ -216,7 +218,7 @@ class SignalTests(unittest.TestCase):
|
|||||||
])
|
])
|
||||||
|
|
||||||
a1.reload()
|
a1.reload()
|
||||||
a1.name='William Shakespeare'
|
a1.name = 'William Shakespeare'
|
||||||
self.assertEqual(self.get_signal_output(a1.save), [
|
self.assertEqual(self.get_signal_output(a1.save), [
|
||||||
"pre_save signal, William Shakespeare",
|
"pre_save signal, William Shakespeare",
|
||||||
"post_save signal, William Shakespeare",
|
"post_save signal, William Shakespeare",
|
||||||
@ -257,3 +259,6 @@ class SignalTests(unittest.TestCase):
|
|||||||
self.assertEqual(self.get_signal_output(ei.save), ['Is created'])
|
self.assertEqual(self.get_signal_output(ei.save), ['Is created'])
|
||||||
# second time, it must be an update
|
# second time, it must be an update
|
||||||
self.assertEqual(self.get_signal_output(ei.save), ['Is updated'])
|
self.assertEqual(self.get_signal_output(ei.save), ['Is updated'])
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user