@@ -592,8 +592,7 @@ class Blog(Document):
592592 Blog .drop_collection ()
593593
594594 def test_update_array_filters (self ):
595- """Ensure that updating by array_filters works.
596- """
595+ """Ensure that updating by array_filters works."""
597596
598597 class Comment (EmbeddedDocument ):
599598 comment_tags = ListField (StringField ())
@@ -605,48 +604,48 @@ class Blog(Document):
605604 Blog .drop_collection ()
606605
607606 # update one
608- Blog .objects .create (tags = [' test1' , ' test2' , ' test3' ])
607+ Blog .objects .create (tags = [" test1" , " test2" , " test3" ])
609608
610- Blog .objects ().update_one (__raw__ =
611- { ' $set' : {"tags.$[element]" : ' test11111' }},
612- array_filters = [{"element" : {' $eq' : ' test2' }}],
613- )
609+ Blog .objects ().update_one (
610+ __raw__ = { " $set" : {"tags.$[element]" : " test11111" }},
611+ array_filters = [{"element" : {" $eq" : " test2" }}],
612+ )
614613 testc_blogs = Blog .objects (tags = "test11111" )
615614
616615 assert testc_blogs .count () == 1
617616
618617 Blog .drop_collection ()
619618
620619 # update one inner list
621- comments = Comment (comment_tags = [' test1' , ' test2' , ' test3' ])
620+ comments = Comment (comment_tags = [" test1" , " test2" , " test3" ])
622621 Blog .objects .create (comments = comments )
623622
624- Blog .objects ().update_one (__raw__ =
625- { ' $set' : {"comments.comment_tags.$[element]" : ' test11111' }},
626- array_filters = [{"element" : {' $eq' : ' test2' }}],
627- )
623+ Blog .objects ().update_one (
624+ __raw__ = { " $set" : {"comments.comment_tags.$[element]" : " test11111" }},
625+ array_filters = [{"element" : {" $eq" : " test2" }}],
626+ )
628627 testc_blogs = Blog .objects (comments__comment_tags = "test11111" )
629628
630629 assert testc_blogs .count () == 1
631630
632631 # update many
633632 Blog .drop_collection ()
634633
635- Blog .objects .create (tags = [' test1' , ' test2' , ' test3' , ' test_all' ])
636- Blog .objects .create (tags = [' test4' , ' test5' , ' test6' , ' test_all' ])
634+ Blog .objects .create (tags = [" test1" , " test2" , " test3" , " test_all" ])
635+ Blog .objects .create (tags = [" test4" , " test5" , " test6" , " test_all" ])
637636
638- Blog .objects ().update (__raw__ =
639- { ' $set' : {"tags.$[element]" : ' test11111' }},
640- array_filters = [{"element" : {' $eq' : ' test2' }}],
641- )
637+ Blog .objects ().update (
638+ __raw__ = { " $set" : {"tags.$[element]" : " test11111" }},
639+ array_filters = [{"element" : {" $eq" : " test2" }}],
640+ )
642641 testc_blogs = Blog .objects (tags = "test11111" )
643642
644643 assert testc_blogs .count () == 1
645644
646- Blog .objects ().update (__raw__ =
647- { ' $set' : {"tags.$[element]" : ' test_all1234577' }},
648- array_filters = [{"element" : {' $eq' : ' test_all' }}],
649- )
645+ Blog .objects ().update (
646+ __raw__ = { " $set" : {"tags.$[element]" : " test_all1234577" }},
647+ array_filters = [{"element" : {" $eq" : " test_all" }}],
648+ )
650649 testc_blogs = Blog .objects (tags = "test_all1234577" )
651650
652651 assert testc_blogs .count () == 2
0 commit comments