Fix modify tests #1565
This commit is contained in:
parent
34fca9d6f5
commit
f09256a24e
@ -103,26 +103,26 @@ class FindAndModifyTest(unittest.TestCase):
|
|||||||
|
|
||||||
BlogPost.drop_collection()
|
BlogPost.drop_collection()
|
||||||
|
|
||||||
BlogPost(id="ABC").save()
|
blog = BlogPost.objects.create()
|
||||||
|
|
||||||
# Push a new tag via modify with new=False (default).
|
# Push a new tag via modify with new=False (default).
|
||||||
blog = BlogPost(pk='ABC').modify(push__tags='code')
|
BlogPost(id=blog.id).modify(push__tags='code')
|
||||||
self.assertEqual(blog.tags, [])
|
self.assertEqual(blog.tags, [])
|
||||||
blog.reload()
|
blog.reload()
|
||||||
self.assertEqual(blog.tags, ['code'])
|
self.assertEqual(blog.tags, ['code'])
|
||||||
|
|
||||||
# Push a new tag via modify with new=True.
|
# Push a new tag via modify with new=True.
|
||||||
blog = BlogPost.objects(pk='ABC').modify(push__tags='java', new=True)
|
blog = BlogPost.objects(id=blog.id).modify(push__tags='java', new=True)
|
||||||
self.assertEqual(blog.tags, ['code', 'java'])
|
self.assertEqual(blog.tags, ['code', 'java'])
|
||||||
|
|
||||||
# Push a new tag with a positional argument.
|
# Push a new tag with a positional argument.
|
||||||
blog = BlogPost.objects(pk='ABC').modify(
|
blog = BlogPost.objects(id=blog.id).modify(
|
||||||
push__tags__0='python',
|
push__tags__0='python',
|
||||||
new=True)
|
new=True)
|
||||||
self.assertEqual(blog.tags, ['python', 'code', 'java'])
|
self.assertEqual(blog.tags, ['python', 'code', 'java'])
|
||||||
|
|
||||||
# Push multiple new tags with a positional argument.
|
# Push multiple new tags with a positional argument.
|
||||||
blog = BlogPost.objects(pk='ABC').modify(
|
blog = BlogPost.objects(id=blog.id).modify(
|
||||||
push__tags__1=['go', 'rust'],
|
push__tags__1=['go', 'rust'],
|
||||||
new=True)
|
new=True)
|
||||||
self.assertEqual(blog.tags, ['python', 'go', 'rust', 'code', 'java'])
|
self.assertEqual(blog.tags, ['python', 'go', 'rust', 'code', 'java'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user