From 0bd2103a8cb10c63371b2d4cefc8809a5d0adc55 Mon Sep 17 00:00:00 2001 From: Andy Yankovsky Date: Tue, 20 Feb 2018 00:02:12 +0300 Subject: [PATCH] Add test for document update --- tests/document/instance.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/document/instance.py b/tests/document/instance.py index 609bc900..22c44ffa 100644 --- a/tests/document/instance.py +++ b/tests/document/instance.py @@ -1341,6 +1341,23 @@ class InstanceTest(unittest.TestCase): site = Site.objects.first() self.assertEqual(site.page.log_message, "Error: Dummy message") + def test_update_list_field(self): + """Test update on `ListField` with $pull + $in. + """ + class Doc(Document): + foo = ListField(StringField()) + + Doc.drop_collection() + doc = Doc(foo=['a', 'b', 'c']) + doc.save() + + # Update + doc = Doc.objects.first() + doc.update(pull__foo__in=['a', 'c']) + + doc = Doc.objects.first() + self.assertEqual(doc.foo, ['b']) + def test_embedded_update_db_field(self): """Test update on `EmbeddedDocumentField` fields when db_field is other than default.