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