@@ -49,9 +49,7 @@ def test_assert_modification_allowed():
4949
5050@pytest .mark .django_db
5151@pytest .mark .parametrize ("reverse" , [True , False ])
52- def test_display_set_permissions_signal (
53- client , reverse , django_capture_on_commit_callbacks
54- ):
52+ def test_display_set_permissions_signal (reverse ):
5553 ds1 , ds2 = DisplaySetFactory .create_batch (2 )
5654 im1 , im2 , im3 , im4 = ImageFactory .create_batch (4 )
5755
@@ -62,19 +60,18 @@ def test_display_set_permissions_signal(
6260 ComponentInterfaceValueFactory (image = im4 ),
6361 )
6462
65- with django_capture_on_commit_callbacks (execute = True ):
66- if reverse :
67- for civ in [civ1 , civ2 , civ3 , civ4 ]:
68- civ .display_sets .add (ds1 , ds2 )
69- for civ in [civ3 , civ4 ]:
70- civ .display_sets .remove (ds1 , ds2 )
71- for civ in [civ1 , civ2 ]:
72- civ .display_sets .remove (ds2 )
73- else :
74- # Test that adding images works
75- ds1 .values .add (civ1 , civ2 , civ3 , civ4 )
76- # Test that removing images works
77- ds1 .values .remove (civ3 , civ4 )
63+ if reverse :
64+ for civ in [civ1 , civ2 , civ3 , civ4 ]:
65+ civ .display_sets .add (ds1 , ds2 )
66+ for civ in [civ3 , civ4 ]:
67+ civ .display_sets .remove (ds1 , ds2 )
68+ for civ in [civ1 , civ2 ]:
69+ civ .display_sets .remove (ds2 )
70+ else :
71+ # Test that adding images works
72+ ds1 .values .add (civ1 , civ2 , civ3 , civ4 )
73+ # Test that removing images works
74+ ds1 .values .remove (civ3 , civ4 )
7875
7976 assert get_groups_with_set_perms (im1 ) == {
8077 ds1 .reader_study .editors_group : {"view_image" },
@@ -88,28 +85,24 @@ def test_display_set_permissions_signal(
8885 assert get_groups_with_set_perms (im4 ) == {}
8986
9087 # Test clearing
91- with django_capture_on_commit_callbacks (execute = True ):
92- if reverse :
93- civ1 .display_sets .clear ()
94- civ2 .display_sets .clear ()
95- else :
96- ds1 .values .clear ()
88+ if reverse :
89+ civ1 .display_sets .clear ()
90+ civ2 .display_sets .clear ()
91+ else :
92+ ds1 .values .clear ()
9793
9894 assert get_groups_with_set_perms (im1 ) == {}
9995 assert get_groups_with_set_perms (im2 ) == {}
10096
10197
10298@pytest .mark .django_db
103- def test_deleting_display_set_removes_permissions (
104- django_capture_on_commit_callbacks ,
105- ):
99+ def test_deleting_display_set_removes_permissions ():
106100 ds1 , ds2 = DisplaySetFactory .create_batch (2 )
107101 im = ImageFactory ()
108102 civ = ComponentInterfaceValueFactory (image = im )
109103
110- with django_capture_on_commit_callbacks (execute = True ):
111- ds1 .values .set ([civ ])
112- ds2 .values .set ([civ ])
104+ ds1 .values .set ([civ ])
105+ ds2 .values .set ([civ ])
113106
114107 assert get_groups_with_set_perms (im ) == {
115108 ds1 .reader_study .editors_group : {"view_image" },
@@ -118,8 +111,7 @@ def test_deleting_display_set_removes_permissions(
118111 ds2 .reader_study .readers_group : {"view_image" },
119112 }
120113
121- with django_capture_on_commit_callbacks (execute = True ):
122- ds1 .delete ()
114+ ds1 .delete ()
123115
124116 assert get_groups_with_set_perms (im ) == {
125117 ds2 .reader_study .editors_group : {"view_image" },
@@ -128,15 +120,12 @@ def test_deleting_display_set_removes_permissions(
128120
129121
130122@pytest .mark .django_db
131- def test_changing_reader_study_updates_permissions (
132- django_capture_on_commit_callbacks ,
133- ):
123+ def test_changing_reader_study_updates_permissions ():
134124 ds = DisplaySetFactory ()
135125 im = ImageFactory ()
136126 civ = ComponentInterfaceValueFactory (image = im )
137127
138- with django_capture_on_commit_callbacks (execute = True ):
139- ds .values .set ([civ ])
128+ ds .values .set ([civ ])
140129
141130 assert get_groups_with_set_perms (im ) == {
142131 ds .reader_study .editors_group : {"view_image" },
@@ -147,8 +136,7 @@ def test_changing_reader_study_updates_permissions(
147136
148137 ds .reader_study = rs
149138
150- with django_capture_on_commit_callbacks (execute = True ):
151- ds .save ()
139+ ds .save ()
152140
153141 assert get_groups_with_set_perms (im ) == {
154142 rs .editors_group : {"view_image" },
0 commit comments