@@ -48,13 +48,6 @@ def get_resource_does_not_exist_exception():
4848 return requests .exceptions .HTTPError (response = response )
4949
5050
51- def get_temporarily_unavailable_exception ():
52- response = requests .Response ()
53- response .status_code = 503
54- response ._content = ('{{"error_code": "{}"}}' .format (api .DbfsErrorCodes .TEMPORARILY_UNAVAILABLE )).encode () # NOQA
55- return requests .exceptions .HTTPError (response = response )
56-
57-
5851def get_partial_delete_exception (message = "[...] operation has deleted 10 files [...]" ):
5952 response = requests .Response ()
6053 response .status_code = 503
@@ -182,33 +175,13 @@ def test_cat(self, dbfs_api):
182175
183176 def test_partial_delete (self , dbfs_api ):
184177 e_partial_delete = get_partial_delete_exception ()
185- e_temporarily_unavailable = get_temporarily_unavailable_exception ()
186- # Simulate partial deletes and 503 exceptions followed by a full successful delete
187- exception_sequence = \
188- [e_temporarily_unavailable , e_partial_delete , e_partial_delete ] + \
189- [e_temporarily_unavailable ] * api .DELETE_MAX_CONSECUTIVE_503_RETRIES + \
190- [e_partial_delete , None ]
178+ # Simulate 3 partial deletes followed by a full successful delete
179+ exception_sequence = [e_partial_delete , e_partial_delete , e_partial_delete , None ]
191180 dbfs_api .client .delete = mock .Mock (side_effect = exception_sequence )
192181 dbfs_api .delete_retry_delay_millis = 1
193182 # Should succeed
194183 dbfs_api .delete (DbfsPath ('dbfs:/whatever-doesnt-matter' ), recursive = True )
195184
196- def test_partial_delete_service_unavailable (self , dbfs_api ):
197- e_partial_delete = get_partial_delete_exception ()
198- e_temporarily_unavailable = get_temporarily_unavailable_exception ()
199- # Simulate more than api.DELETE_MAX_CONSECUTIVE_503_ERRORS 503 errors that are not partial
200- # deletes (error_code != PARTIAL_DELETE)
201- exception_sequence = \
202- [e_partial_delete ] + \
203- [e_temporarily_unavailable ] * (api .DELETE_MAX_CONSECUTIVE_503_RETRIES + 1 ) + \
204- [e_partial_delete , None ]
205- dbfs_api .client .delete = mock .Mock (side_effect = exception_sequence )
206- dbfs_api .delete_retry_delay_millis = 1
207- with pytest .raises (e_temporarily_unavailable .__class__ ) as thrown :
208- dbfs_api .delete (DbfsPath ('dbfs:/whatever-doesnt-matter' ), recursive = True )
209- # Should raise the same e_temporarily_unavailable exception instance
210- assert thrown .value == e_temporarily_unavailable
211-
212185 def test_partial_delete_exception_message_parse_error (self , dbfs_api ):
213186 message = "unexpected partial delete exception message"
214187 e_partial_delete = get_partial_delete_exception (message )
0 commit comments