Fix #595: Support += and *= for ListField

This commit is contained in:
David Bordeynik
2015-03-29 09:28:26 +03:00
parent cbd2a44350
commit de0e5583a5
3 changed files with 24 additions and 0 deletions

View File

@@ -946,6 +946,18 @@ class FieldTest(unittest.TestCase):
BlogPost.objects.filter(info__0__test__exact='5').count(), 0)
self.assertEqual(
BlogPost.objects.filter(info__100__test__exact='test').count(), 0)
post = BlogPost()
post.info = ['1', '2']
post.save()
post = BlogPost.objects(info=['1', '2']).get()
post.info += ['3', '4']
post.save()
self.assertEqual(BlogPost.objects(info=['1', '2', '3', '4']).count(), 1)
post = BlogPost.objects(info=['1', '2', '3', '4']).get()
post.info *= 2
post.save()
self.assertEqual(BlogPost.objects(info=['1', '2', '3', '4', '1', '2', '3', '4']).count(), 1)
BlogPost.drop_collection()
def test_list_field_passed_in_value(self):