added test cases for update pull queries
This commit is contained in:
		| @@ -248,6 +248,30 @@ class TransformTest(unittest.TestCase): | |||||||
|         with self.assertRaises(InvalidQueryError): |         with self.assertRaises(InvalidQueryError): | ||||||
|             events.count() |             events.count() | ||||||
|      |      | ||||||
|  |     def test_update_pull_for_list_fields(self): | ||||||
|  |         """  | ||||||
|  |         Test added to check pull operation in update for  | ||||||
|  |         EmbeddedDocumentListField which is inside a EmbeddedDocumentField | ||||||
|  |         """ | ||||||
|  |         class Word(EmbeddedDocument): | ||||||
|  |             word = StringField() | ||||||
|  |             index = IntField() | ||||||
|  |          | ||||||
|  |         class SubDoc(EmbeddedDocument): | ||||||
|  |             heading = ListField(StringField()) | ||||||
|  |             text = EmbeddedDocumentListField(Word) | ||||||
|  |          | ||||||
|  |         class MainDoc(Document): | ||||||
|  |             title = StringField() | ||||||
|  |             content = EmbeddedDocumentField(SubDoc) | ||||||
|  |          | ||||||
|  |         word = Word(word='abc', index=1) | ||||||
|  |         update = transform.update(MainDoc, pull__content__text=word) | ||||||
|  |         self.assertEqual(update, {'$pull': {'content.text': SON([('word', u'abc'), ('index', 1)])}}) | ||||||
|  |  | ||||||
|  |         update = transform.update(MainDoc, pull__content__heading='xyz') | ||||||
|  |         self.assertEqual(update, {'$pull': {'content.heading': 'xyz'}}) | ||||||
|  |          | ||||||
|          |          | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     unittest.main() |     unittest.main() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user