'Ensure that updating by array position works.
Check update() and update_one() can take syntax like:
set__posts__1__comments__1__name="testc"
Check that it only works for ListFields.'

def test_update_array_position(self):

    class Comment(EmbeddedDocument, ):
        name = StringField()
    class Post(EmbeddedDocument, ):
        comments = ListField(EmbeddedDocumentField(Comment))
    class Blog(Document, ):
        tags = ListField(StringField())
        posts = ListField(EmbeddedDocumentField(Post))
    Blog.drop_collection()
    comment1 = Comment(name='testa')
    comment2 = Comment(name='testb')
    post1 = Post(comments=[comment1, comment2])
    post2 = Post(comments=[comment2, comment2])
    Blog.objects.create(posts=[post1, post2])
    Blog.objects.create(posts=[post2, post1])
    Blog.objects().update(set__posts__1__comments__0__name='testc')
    testc_blogs = Blog.objects(posts__1__comments__0__name='testc')
    self.assertEqual(testc_blogs.count(), 2)
    Blog.drop_collection()
    Blog.objects.create(posts=[post1, post2])
    Blog.objects.create(posts=[post2, post1])
    Blog.objects().update_one(set__posts__1__comments__1__name='testc')
    testc_blogs = Blog.objects(posts__1__comments__1__name='testc')
    self.assertEqual(testc_blogs.count(), 1)
    with self.assertRaises(InvalidQueryError):
        Blog.objects().update(set__posts__1__comments__0__name__1='asdf')
    Blog.drop_collection()
