fix EmbeddedDocumentListFieldTestCase
This commit is contained in:
parent
b27c7ce11b
commit
3fe8031cf3
@ -218,9 +218,9 @@ class FieldTest(MongoDBTestCase):
|
||||
self.assertTrue(isinstance(ret.comp_dt_fld, datetime.datetime))
|
||||
|
||||
def test_not_required_handles_none_from_database(self):
|
||||
"""Ensure that every fields can handle null values from the database.
|
||||
"""Ensure that every field can handle null values from the
|
||||
database.
|
||||
"""
|
||||
|
||||
class HandleNoneFields(Document):
|
||||
str_fld = StringField(required=True)
|
||||
int_fld = IntField(required=True)
|
||||
@ -4031,12 +4031,13 @@ class FieldTest(MongoDBTestCase):
|
||||
self.assertTrue(isinstance(doc.some_long, six.integer_types))
|
||||
|
||||
|
||||
class EmbeddedDocumentListFieldTestCase(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.db = connect(db='EmbeddedDocumentListFieldTestCase')
|
||||
class EmbeddedDocumentListFieldTestCase(MongoDBTestCase):
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Create two BlogPost entries in the database, each with
|
||||
several EmbeddedDocuments.
|
||||
"""
|
||||
class Comments(EmbeddedDocument):
|
||||
author = StringField()
|
||||
message = StringField()
|
||||
@ -4044,14 +4045,11 @@ class EmbeddedDocumentListFieldTestCase(unittest.TestCase):
|
||||
class BlogPost(Document):
|
||||
comments = EmbeddedDocumentListField(Comments)
|
||||
|
||||
cls.Comments = Comments
|
||||
cls.BlogPost = BlogPost
|
||||
BlogPost.drop_collection()
|
||||
|
||||
self.Comments = Comments
|
||||
self.BlogPost = BlogPost
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Create two BlogPost entries in the database, each with
|
||||
several EmbeddedDocuments.
|
||||
"""
|
||||
self.post1 = self.BlogPost(comments=[
|
||||
self.Comments(author='user1', message='message1'),
|
||||
self.Comments(author='user2', message='message1')
|
||||
@ -4063,13 +4061,6 @@ class EmbeddedDocumentListFieldTestCase(unittest.TestCase):
|
||||
self.Comments(author='user3', message='message1')
|
||||
]).save()
|
||||
|
||||
def tearDown(self):
|
||||
self.BlogPost.drop_collection()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.db.drop_database('EmbeddedDocumentListFieldTestCase')
|
||||
|
||||
def test_no_keyword_filter(self):
|
||||
"""
|
||||
Tests the filter method of a List of Embedded Documents
|
||||
@ -4436,12 +4427,12 @@ class EmbeddedDocumentListFieldTestCase(unittest.TestCase):
|
||||
class B(Document):
|
||||
my_list = ListField(EmbeddedDocumentField(EmbeddedWithSparseUnique))
|
||||
|
||||
B(my_list=[]).save()
|
||||
B(my_list=[]).save()
|
||||
|
||||
A.drop_collection()
|
||||
B.drop_collection()
|
||||
|
||||
B(my_list=[]).save()
|
||||
B(my_list=[]).save()
|
||||
|
||||
def test_filtered_delete(self):
|
||||
"""
|
||||
Tests the delete method of a List of Embedded Documents
|
||||
@ -4478,6 +4469,8 @@ class EmbeddedDocumentListFieldTestCase(unittest.TestCase):
|
||||
a_field = IntField()
|
||||
c_field = IntField(custom_data=custom_data)
|
||||
|
||||
CustomData.drop_collection()
|
||||
|
||||
a1 = CustomData(a_field=1, c_field=2).save()
|
||||
self.assertEqual(2, a1.c_field)
|
||||
self.assertFalse(hasattr(a1.c_field, 'custom_data'))
|
||||
|
Loading…
x
Reference in New Issue
Block a user