@@ -767,21 +767,22 @@ def test_models_documents_nb_accesses_cache_is_invalidated_on_access_removal(
767
767
assert cache .get (key ) == 0 # Cache should now contain the new value
768
768
769
769
770
- def test_models_documents_restore ():
770
+ def test_models_documents_restore (django_assert_num_queries ):
771
771
"""The restore method should restore a soft-deleted document."""
772
772
document = factories .DocumentFactory ()
773
773
document .soft_delete ()
774
774
document .refresh_from_db ()
775
775
assert document .deleted_at is not None
776
776
assert document .ancestors_deleted_at == document .deleted_at
777
777
778
- document .restore ()
778
+ with django_assert_num_queries (6 ):
779
+ document .restore ()
779
780
document .refresh_from_db ()
780
781
assert document .deleted_at is None
781
782
assert document .ancestors_deleted_at == document .deleted_at
782
783
783
784
784
- def test_models_documents_restore_complex ():
785
+ def test_models_documents_restore_complex (django_assert_num_queries ):
785
786
"""The restore method should restore a soft-deleted document and its ancestors."""
786
787
grand_parent = factories .DocumentFactory ()
787
788
parent = factories .DocumentFactory (parent = grand_parent )
@@ -817,7 +818,8 @@ def test_models_documents_restore_complex():
817
818
assert child2 .ancestors_deleted_at == document .deleted_at
818
819
819
820
# Restore the item
820
- document .restore ()
821
+ with django_assert_num_queries (8 ):
822
+ document .restore ()
821
823
document .refresh_from_db ()
822
824
child1 .refresh_from_db ()
823
825
child2 .refresh_from_db ()
@@ -829,7 +831,7 @@ def test_models_documents_restore_complex():
829
831
assert child2 .ancestors_deleted_at == grand_parent .deleted_at
830
832
831
833
832
- def test_models_documents_restore_complex_bis ():
834
+ def test_models_documents_restore_complex_bis (django_assert_num_queries ):
833
835
"""The restore method should restore a soft-deleted item and its ancestors."""
834
836
grand_parent = factories .DocumentFactory ()
835
837
parent = factories .DocumentFactory (parent = grand_parent )
@@ -866,7 +868,9 @@ def test_models_documents_restore_complex_bis():
866
868
867
869
# Restoring the grand parent should not restore the document
868
870
# as it was deleted before the grand parent
869
- grand_parent .restore ()
871
+ with django_assert_num_queries (7 ):
872
+ grand_parent .restore ()
873
+
870
874
grand_parent .refresh_from_db ()
871
875
parent .refresh_from_db ()
872
876
document .refresh_from_db ()
0 commit comments