@@ -98,9 +98,8 @@ def test_health_check_auth_error(self, mock_storage):
9898 with patch (
9999 "django_rustfs.management.commands.rustfs_health.RustFSStorage" ,
100100 return_value = mock_storage ,
101- ):
102- with pytest .raises (CommandError ) as exc_info :
103- call_command ("rustfs_health" , stdout = out )
101+ ), pytest .raises (CommandError ) as exc_info :
102+ call_command ("rustfs_health" , stdout = out )
104103
105104 assert "Authentication failed" in str (exc_info .value )
106105
@@ -116,9 +115,8 @@ def test_health_check_invalid_access_key(self, mock_storage):
116115 with patch (
117116 "django_rustfs.management.commands.rustfs_health.RustFSStorage" ,
118117 return_value = mock_storage ,
119- ):
120- with pytest .raises (CommandError ) as exc_info :
121- call_command ("rustfs_health" , stdout = out )
118+ ), pytest .raises (CommandError ) as exc_info :
119+ call_command ("rustfs_health" , stdout = out )
122120
123121 assert "Authentication failed" in str (exc_info .value )
124122
@@ -134,9 +132,8 @@ def test_health_check_signature_error(self, mock_storage):
134132 with patch (
135133 "django_rustfs.management.commands.rustfs_health.RustFSStorage" ,
136134 return_value = mock_storage ,
137- ):
138- with pytest .raises (CommandError ) as exc_info :
139- call_command ("rustfs_health" , stdout = out )
135+ ), pytest .raises (CommandError ) as exc_info :
136+ call_command ("rustfs_health" , stdout = out )
140137
141138 assert "Authentication failed" in str (exc_info .value )
142139
@@ -152,9 +149,8 @@ def test_health_check_bucket_other_error(self, mock_storage):
152149 with patch (
153150 "django_rustfs.management.commands.rustfs_health.RustFSStorage" ,
154151 return_value = mock_storage ,
155- ):
156- with pytest .raises (CommandError ) as exc_info :
157- call_command ("rustfs_health" , stdout = out )
152+ ), pytest .raises (CommandError ) as exc_info :
153+ call_command ("rustfs_health" , stdout = out )
158154
159155 assert "Bucket check failed" in str (exc_info .value )
160156
@@ -166,9 +162,8 @@ def test_health_check_connection_error(self, mock_storage):
166162 with patch (
167163 "django_rustfs.management.commands.rustfs_health.RustFSStorage" ,
168164 return_value = mock_storage ,
169- ):
170- with pytest .raises (CommandError ) as exc_info :
171- call_command ("rustfs_health" , stdout = out )
165+ ), pytest .raises (CommandError ) as exc_info :
166+ call_command ("rustfs_health" , stdout = out )
172167
173168 assert "Cannot connect to RustFS" in str (exc_info .value )
174169
@@ -179,9 +174,8 @@ def test_health_check_config_error(self):
179174 with patch (
180175 "django_rustfs.management.commands.rustfs_health.RustFSStorage" ,
181176 side_effect = ImproperlyConfigured ("Missing endpoint" ),
182- ):
183- with pytest .raises (CommandError ) as exc_info :
184- call_command ("rustfs_health" , stdout = out )
177+ ), pytest .raises (CommandError ) as exc_info :
178+ call_command ("rustfs_health" , stdout = out )
185179
186180 assert "Configuration error" in str (exc_info .value )
187181
@@ -272,14 +266,13 @@ def test_init_buckets_success(self, mock_storage):
272266 with patch (
273267 "django_rustfs.management.commands.rustfs_init_buckets.RustFSStorage" ,
274268 return_value = mock_storage ,
275- ):
276- with patch (
277- "django_rustfs.management.commands.rustfs_init_buckets.RustFSStaticStorage"
278- ) as mock_static :
279- mock_static_storage = MagicMock ()
280- mock_static_storage .bucket_name = "django-static"
281- mock_static .return_value = mock_static_storage
282- call_command ("rustfs_init_buckets" , stdout = out )
269+ ), patch (
270+ "django_rustfs.management.commands.rustfs_init_buckets.RustFSStaticStorage"
271+ ) as mock_static :
272+ mock_static_storage = MagicMock ()
273+ mock_static_storage .bucket_name = "django-static"
274+ mock_static .return_value = mock_static_storage
275+ call_command ("rustfs_init_buckets" , stdout = out )
283276
284277 output = out .getvalue ()
285278 assert "Initializing RustFS buckets" in output
@@ -360,9 +353,8 @@ def test_init_buckets_config_error(self):
360353 with patch (
361354 "django_rustfs.management.commands.rustfs_init_buckets.RustFSStorage" ,
362355 side_effect = ImproperlyConfigured ("Missing endpoint" ),
363- ):
364- with pytest .raises (CommandError ) as exc_info :
365- call_command ("rustfs_init_buckets" , stdout = out )
356+ ), pytest .raises (CommandError ) as exc_info :
357+ call_command ("rustfs_init_buckets" , stdout = out )
366358
367359 assert "Configuration error" in str (exc_info .value )
368360
@@ -374,12 +366,11 @@ def test_init_buckets_static_storage_error(self, mock_storage):
374366 with patch (
375367 "django_rustfs.management.commands.rustfs_init_buckets.RustFSStorage" ,
376368 return_value = mock_storage ,
369+ ), patch (
370+ "django_rustfs.management.commands.rustfs_init_buckets.RustFSStaticStorage" ,
371+ side_effect = Exception ("Static config error" ),
377372 ):
378- with patch (
379- "django_rustfs.management.commands.rustfs_init_buckets.RustFSStaticStorage" ,
380- side_effect = Exception ("Static config error" ),
381- ):
382- call_command ("rustfs_init_buckets" , stdout = out )
373+ call_command ("rustfs_init_buckets" , stdout = out )
383374
384375 output = out .getvalue ()
385376 assert "Could not configure static storage" in output
0 commit comments